Solved

export template class in MFC extension DLL

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
cat dog challenge 18 124
Expand data scrubbing tool 13 32
withoutTen challenge 14 121
Remove Password Protection from pdf (with password) using an command line executable 5 50
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
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.

770 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