Jump to content
  • Advertisement
Sign in to follow this  
The Lion King

std::string

This topic is 5052 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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 ???

Share this post


Link to post
Share on other sites
Advertisement
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!