std::string

Started by
5 comments, last by The Lion King 19 years, 7 months ago
I am using std::string in a class. When I compile the compiler gives me this warning ...

warning C4251: 'cString::TxtString' : class 'std::basic_string<_Elem,_Traits,_Ax>' needs to have dll-interface to be used by clients of class 'cString'
        with
        [
            _Elem=char,
            _Traits=std::char_traits<char>,
            _Ax=std::allocator<char>
        ]
And when I put it outside the class ... no error. What am I doing wrong? MSDN says that I need a dll export interface or something ???
Advertisement
could you post the code?

-me
I'm a bit confused to.

but
__declspec(dllexport) 
is the dll export string

void __declspec(dllexport) foo()
This issue is due to the STL templates classes.
Generally you can safely ignore this warning. It will always occur if you use STL clases as parameter or output in your public class interface while linking the static lib version of the C/C++ runtime. Changing the project settings to Multi(or Single)-Threaded DLL might help with that.

Hope this helps (and is somewhat technically correct - it's 4am at my place [wink]),
Pat
Actually ... I am making a String class. Where I have std::string inside it. The class is in a DLL and has __declspec(dllexport) with it.

When I keep it in the class ... it gives me this warning ... and when I take it outside the calss ... its 100% OK without any warning or errors.
In that case - ignore the warning.
Quote:Original post by darookie
In that case - ignore the warning.

LOL ... OK!

This topic is closed to new replies.

Advertisement