ManticMoo.COM -> Jeff's Articles -> Programming Articles -> Visual C++ -> Suppressing deprecation warnings when upgrading to Visual Studio 2005
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Suppressing deprecation warnings when upgrading to Visual Studio 2005by Jeffrey P. BighamI was recently tasked with migrating a simple, internal application from VS2003 to VS2005. You would think this would be really simple, and it really wasn't that hard, but there are a few gotcha's that you have to watch out for when doing so. In its infinite wisdom Microsoft decided that as of Visual Studio 2005, basically all of the standard C functions dealing with strings that rely on an ending NULL character and not a specified length would be deprecated. This means that strcpy, sprintf and strlen are all deprecated to name just a few. In some respects this is a good thing because it might help to convince programmers to use the more secure variations of these standard functions, but, unfortunately, it also causes applications that used to compile cleanly to issue thousands of warnings. Futhermore, switching to the more secure variations of the functions isn't always trivially because to use them you must know the length of the buffers, which might not be easily accessible in many programs not designed for it. And, not to mention, if you use the secure functions you give up all hope of being able to compile your C++ code in Unix. Avoidance by SuppressionThere may be a better way of getting rid of these warning, but until there is I'm just going to suppress them. I want to be as particular as possible with the warnings that I suppress to make sure that I'm not suppressing something useful. Therefore, I picked out the particular warning code associated with these warnings, code 4996, and suppress only warnings of that type.
To suppress these warnings simply add the following compiler directive: In Visual Studio this can be found in the Properties of your project, under C/C++, in the Commandline option. List of newly deprecated functions in VS2005 and their secure alternative
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ManticMoo.COM -> Jeff's Articles -> Programming Articles -> Visual C++ -> Suppressing deprecation warnings when upgrading to Visual Studio 2005
|