Sunday, August 15, 2010

Removing Warning messages while compiling old MFC programs in Visual c++ 2008


While compiling old MFC programs in Visual c++ 2008 environment, we get a huge number of warnings. These are mainly of two kind.

(1) The first kind is:
  • strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
  • 'strcat': This function or variable may be unsafe. Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
To remove these warnings, go to "Project->Properties->Configuration Properties->C/C++->Preprocessor->Preprocessor Definitions" and add "_CRT_SECURE_NO_WARNINGS"

(2) The other warnings are of following form:
  • 'strdup': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _strdup. See online help for details.
  • 'stricmp': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _stricmp. See online help for details.
To remove these warnings, go to "Project->Properties->Configuration Properties->C/C++->Preprocessor->Preprocessor Definitions" and add "_CRT_NONSTDC_NO_DEPRECATE"