<?php
$title="Suprressing deprecation warnings when upgrading to Visual Studio 2005";
$author="Jeffrey P. Bigham";
?>
<? include('header.php'); ?>

<p>
I 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.
</p>

<p>
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 should get programmers to use the more secure variations, but unfortunately, it can also cause applications that used to compile cleanly to issue thousands of warnings.  Furthermore, 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.
</p>

<h2>Avoidance by Suppression</h2>

<p>
There 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.
</p>

<p>
To suppress these warnings simply at the compiler directive:<br>

<code>
<pre>
/wd4996
</pre>
</code>

to your commandline options.
</p>

<p>
In Visual Studio this can be found in the Properties of your project, under C/C++, in the Commandline option.
</p>


<h2>List of newly deprecated functions in VS2005</h2>




<? include('footer.php'); ?>