when I compiled old MTPRINTX demo from Revo MFC book, I got the following error messages:
Error C4996 '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. MTPRINTX c:\demo_revo\mtprintx\mtprintx\hexvivw.cpp 38
I searched internet, stackoverflow.com has some good posts:
-
How to get rid of “unsafe” warnings / errors in Visual Studio (strcpy, sprintf, strdup)
a good solution:
If you are on visual studio version >= 2005 and want to fix these warnings in a proper way... easiest method is to #define _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES 1 and #define _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES_COUNT 1 in your project.
-
Secure Template Overloads
Many CRT functions have been deprecated in favor of newer, security-enhanced versions (for example, strcpy_s is the more secure replacement for strcpy). The CRT provides template overloads to help ease the transition to the more secure variants.
-
strcpy() error in Visual studio 2012
I tested:
but it would be a good idea to add
_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
as to inherit predefined definitions
IMHO & for the most part this is a good approach.
-
How to fix compile error “This function or variable may be unsafe” (strcpy)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-