Sunday, July 24, 2011

_CRT_SECURE_NO_WARNINGS Error Message in Visual Studio 2010 (VC++)

Using "legacy"/"unsecure" I/O functions in Visual Studio 2010 would trigger error similar to this:

1>emufuncs.cpp(672): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\stdio.h(234) : see declaration of 'fopen'

which results in this error:

1>peutils.cpp(64): error C3861: 'dont_use_fgetc': identifier not found
1>peutils.cpp(224): error C3861: 'dont_use_fseek': identifier not found
1>peutils.cpp(229): error C3861: 'dont_use_fread': identifier not found
1>peutils.cpp(247): error C3861: 'dont_use_ftell': identifier not found

If you insist on using the "legacy" code, the solution is to define the following preprocessor definitions in your Visual Studio 2010 project properties:


The preprocessor definition can be accessed in this menu: Project|Properties(Alt+F7)|Configuration Properties|C/C++|Preprocessor|Preprocessor Definitions.

After defining USE_STANDARD_FILE_FUNCTIONS;_CRT_SECURE_NO_WARNINGS; in your Visual C++ project, you should be good to go.

Happy coding.
Post a Comment

No comments: