Sign in to follow this  
Iccarus

VS2005 - deprecated functions

Recommended Posts

Iccarus    122
I've just got MS VS 2005 standard edition and have converted my project over from MS 2003.NET. When I try and compile it though I get 283 warnings of deprecated functions in the string.h class. Is there anything I can do to stop this?

Share this post


Link to post
Share on other sites
jdhardy    469
Don't use those functions, because they're unsafe?

IF you feel like living on the edge, disable warning 4996: Project->Properties->C/C++->Advanced->Disable specific warnings

EDIT: Wait, string.h class? If you're using C++ and you want the C string functions (strncat, strncmp et al.) use #include <cstring>; if you want the C++ std::string class, use #include <string>. If you're using C, string.h is still valid.

Share this post


Link to post
Share on other sites
hplus0603    11356

#pragma warning(disable: 4996)
#include <string.h>



Note that strncpy() isn't necessarily "dangerous" but is still considered deprecated by Microsoft. In fact, strcpy() isn't "dangerous" either if you know what you're doing, which you're SUPPOSED to do when you're programming.

Thought: On the other hand, a programmer who doesn't know what he's doing can be dangerous, even if given just a dull spoon and a paper napkin -- so, perhaps the problem is that programmers aren't necessarily required to pass stringent exams like bridge engineers and architects, rather than whether strcpy() will give you a warning or not...

Share this post


Link to post
Share on other sites
Iccarus    122
I am already just including <string>. I'm not using strcpy() (AFAIK - I'm pretty sure I've converted everything to c++ strings.)

Share this post


Link to post
Share on other sites
Arild Fines    968
Quote:
Original post by hplus0603
In fact, strcpy() isn't "dangerous" either if you know what you're doing, which you're SUPPOSED to do when you're programming.

No programmers know what they're doing. Good programmers recognize that they don't know what they're doing, and choose their tools accordingly.

Even a programmer who knows the weaknesses of strcpy can still get it wrong due to faulty higher level assumptions.

Share this post


Link to post
Share on other sites

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