Jump to content
  • Advertisement
Sign in to follow this  
Decept

boost format problem

This topic is 3672 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'm new to std::string and boost::format and such. Im trying to do the following:
int value = 5;
format fmter( "Testing stuff %1%" );
fmter % value;

the second line gives a very long warning, here is part of it: warning C4996: 'std::char_traits<char>::copy': Function call with parameters that may be unsafe - this call relies on the caller to check that the passed values are correct. Am I doing something wrong? I've searched around and this seems to be the way to do it.

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by Decept
I'm new to std::string and boost::format and such. Im trying to do the following:

*** Source Snippet Removed ***

the second line gives a very long warning, here is part of it:

warning C4996: 'std::char_traits<char>::copy': Function call with parameters that may be unsafe - this call relies on the caller to check that the passed values are correct.

Am I doing something wrong? I've searched around and this seems to be the way to do it.


That warning is for 'depracated functions' as determined by microsoft. In an effort to curb common bugs when dealing with C-style strings Microsoft's visual C++ team has made 'safe' versions of many standard library functions, one of which is std::char_traits<T>::copy. Boost uses this member function in its headers so Visual C++ flags it as a warning.

You can either ignore the warning every time you compile, use a compiler directive to ignore the warning (see the example programs. The #pragma is commented out, just uncomment it to use), modify boost to use the safe versions, or drop boost entirely.

Maybe in future versions of boost they will fix the warning for MS compilers.

Share this post


Link to post
Share on other sites
Your code should be correct. It's Microsoft again going and deprecating stuff that is perfectly standard and OK to use.

You should probably trust that your boost implementation is correct and Google for a way to turn warnings of this kind off (or just ignore "deprecated"-warnings).

Share this post


Link to post
Share on other sites
Defining _SCL_SECURE_NO_DEPRECATE (_SCL_SECURE_NO_WARNINGS in VC9) and _CRT_SECURE_NO_DEPRECATE in your project settings, or somewhere sufficiently early in the code, should also do the trick.

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!