nav-left cat-right
cat-right
Matthias Pospiech > Programming > C++ > MFC > Disable deprecation of functions

Disable deprecation of functions

When using old functions in MFC which happens quite easily when one imports old VS6 examples or has to use old projects one gets this warning quite often:

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. c:\programme\microsoft visual studio 8\vc\include\stdio.h(234): Siehe Deklaration von ‚fopen‘

The solution is to add the following lines to the main .h file (which is StdAfx.h when using MFC):

#define _CRT_SECURE_NO_WARNINGS
#define _CRT_SECURE_NO_DEPRECATE
#define _SCL_SECURE_NO_DEPRECATE

or, to add these values to the Preprocessor definition list. This works in any case with any Toolkit

This line was not obvious to me after this warning line. Now I know how to deals with such messages.

The better solution would be to rewrite the code, but most of the warnings are so weird that it is not fun nor is it easy to change the code.

Einen Kommentar schreiben

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.

*

This blog is kept spam free by WP-SpamFree.