export classes using std namespace (ex std::vector) in a DLL 
Author Message
 export classes using std namespace (ex std::vector) in a DLL

Hello,

I'm trying to create a DLL. I want my classes to be
accessible (using __declspec(dllexport)).

The problem is that "the class std::vector needs to have
dll-interface to be used by clients of class c..."

What can I do to avoid this message ?

Thanks



Sun, 09 Oct 2005 20:41:45 GMT  
 export classes using std namespace (ex std::vector) in a DLL

Quote:

>Hello,

>I'm trying to create a DLL. I want my classes to be
>accessible (using __declspec(dllexport)).

>The problem is that "the class std::vector needs to have
>dll-interface to be used by clients of class c..."

>What can I do to avoid this message ?

#pragma warning(disable) can help. :) As std::vector is a template, it can
be instantiated everywhere it's needed, and it's not the end of the world.
The situation is that the DLL and its client have their own independent
vector code implementations. (Template static data is another issue, but
vector has none, so you're safe in that respect) What does this imply? Two
things. There is some code bloat, which is minimal for a class like vector.
Potentially more troublesome is the versioning aspect. To avoid the DLL and
its clients getting out of step in their vector implementations, you
shouldn't, say, update your compiler and then compile one but not the other.
But hey, you're using __declspec(dllexport) on a class, so you pretty much
can't do that anyway. So you're left with a probably insignificant code
bloat issue. To fix that, you could explicitly instantiate and export all
the template specializations your exported classes use, but that gets to be
a pain. It's easy to forget, and there are other contexts in which the
compiler won't warn about cross-module usage. So I wouldn't feel too bad
about ignoring the warning.

P.S. Please include the warning number in future messages. For example, this
one is C4251. Makes it easier to google. :)

--
Doug Harrison
Microsoft MVP - Visual C++



Mon, 10 Oct 2005 00:31:38 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. using std::string and vector in DLL exported class

2. problem using std::string in exported class to be puit in a DLL

3. using std::string in my dll-exported class

4. std::vector passed to DLL class never arrives???

5. std::vector crash using with DLL?

6. bug: VS7.0 (6.0) C++ std::auto_ptr conflict with std::vector

7. Warnings for std::vector<std::string>

8. typedef std::vector<std::string> Vector_String

9. std::list, std::vector, push_back() and associated ::iterator validity

10. std::vector holding different class types sharing a same base class

11. Passing std::set and std::map objects between 2 dlls

12. Using namespace std together with ifsream

 

 
Powered by phpBB® Forum Software