Solved

export template class in MFC extension DLL

Posted on 1998-02-08
3
508 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Windows Drag & Drop Location 2 94
notReplace  challenge 53 115
viewing source code from eclipse 13 88
only14 challenge 19 68
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
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. …
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.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

948 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

20 Experts available now in Live!

Get 1:1 Help Now