Solved

export template class in MFC extension DLL

Posted on 1998-02-08
3
530 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
conditional code and condition difference 9 87
matchUp  challenge 6 83
Not needed 13 134
Message not shown 5 107
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

752 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