Warning C4251 when building a DLL that exports a class containing an ATL::CString member

This thread gives what I consider a better answer, by Doug Harrison (VC++ MVP):

[This warning is] emitted when you use a non-dllexported class X in a dllexported class Y. What's so bad about that? Well, suppose Y has an inline function y_f that calls a function x_f belonging to X that is not also inline. If y_f is inlined inside some client that doesn't statically link X, the link will fail, because x_f won't be found.


This Microsoft page helped me with it.

How to export an instantiation of a Standard Template Library (STL) class and a class that contains a data member that is an STL object


Here is a thread with a good discussion of this.

In short, the compiler is warning you that, in effect, your exported class does not seperate the interface from the implementation. If the members in question are not accessible to the clients, make them private and #pragma away the warning for that member/class. If the members are accessible and used by clients, then you will need to provide indirect access to the members through accessors and mutators.