<p>With the <em>Visual Studio 2005 C++ compiler</em>, I get the following warning when my code uses the <code>fopen()</code> and such calls:</p>
<pre class="lang-none prettyprint-override"><code>1&gt;foo.cpp(5) : warning C4996: 'fopen' was declared deprecated
1&gt;        c:\program files\microsoft visual studio 8\vc\include\stdio.h(234) : see declaration of 'fopen'
1&gt;        Message: 'This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_DEPRECATE. See online help for details.'
</code></pre>
<p>How do I prevent this?</p>

It looks like Microsoft has deprecated lots of calls which use buffers to improve code security. However, the solutions they're providing aren't portable. Anyway, if you aren't interested in using the secure version of their calls (like
fopen_s
), you need to place a definition of
_CRT_SECURE_NO_DEPRECATE
before your included header files. For example:
```
```
#define _CRT_SECURE_NO_DEPRECATE
#include <stdio.h>
```
```
The preprocessor directive can also be added to your project settings to effect it on all the files under the project. To do this add
_CRT_SECURE_NO_DEPRECATE
to
Project Properties -> Configuration Properties -> C/C++ -> Preprocessor -> Preprocessor Definitions
.