Sign in to follow this  

std::string

This topic is 4838 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
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

This topic is 4838 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this