Solved

export template class in MFC extension DLL

Posted on 1998-02-08
3
500 Views
Last Modified: 2013-11-19
I know I can't export a template class in MFC extension DLL bu doing

template<class T>
class AFX_EXT_CLASS CSharedMemT: public CObject
{
...

I was told to "explicitly instantiate the template-based classes I really want to export, and export those on a case-by-case basis"

My Q is, how do I do that in the MFC extension DLL? I need shor, simple deom code on how this can be implemented.

Thanks

Joshua
0
Comment
Question by:joshual
  • 2
3 Comments
 
LVL 7

Expert Comment

by:galkin
ID: 1315820
You cannot export template clas. Instaed you must define all functions of the template class as inline(wighout __declspec(_dllexport)) and simply include header whre you want to use it. Template class is actually created by compiler based on parameter passed.
0
 

Author Comment

by:joshual
ID: 1315821
What is the point of exporting the function when you can't export the class? As I have said in my Q, maybe can you show me a short smaple program.

Thanks.

0
 
LVL 7

Accepted Solution

by:
galkin earned 100 total points
ID: 1315822
Look at any of MFC template collection classes CList, CArray, CMap. You will find that all their functions are implemented as inline. Inline function are not exported from a DLL so these classes are not exported from MFC42.DLL. Instead each time you use either of them compiler creates new class based on template parameter(s) and code is added to your DLL or EXE which uses this template classes. So you must do the same. You must distribute template class header with inline functions
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This video discusses moving either the default database or any database to a new volume.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now