DLL and templates

B

Bolin

I was wondering how to properly export template classes that are
defined in a library. The problem is that this library defines a
template class:

template <typename T> class A {...};

and another class that uses a specific implementation of A, say

class B { class A<int> m_a; ...};

Following what I have read here and there, I exported class B, I did
not exported the templated class A, but exported class A<int>.

However, when compiling an executable against this library, for all
member function of A that are not inline (say, function 'setX'), I get
the following warning (using VC++6.0):

warning C4273: 'setX' : inconsistent dll linkage. dllexport assumed.
c:\program files\microsoft visual
studio\vc98\include\xmemory(59) :
while compiling class-template member function 'void __thiscall
A<int>::setX(int)'

The executable seems to run fine though. But I was wondering if I was
doing things correctly or if I missed a point.

Thanks for your help,

B.
 
J

Jack Klein

I was wondering how to properly export template classes that are
defined in a library. The problem is that this library defines a
template class:

Try a group like or one of
Microsoft's support groups in the This is
not a language issue, there is no such thing as a DLL in the C++
language, it is a Windows thing.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++ ftp://snurse-l.org/pub/acllc-c++/faq
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,143
Latest member
DewittMill
Top