Search code examples
c++visual-studiovisual-c++deprecatedcrt

CRT deprecation warnings


According to Security Enhancements in the CRT and Secure Template Overloads, it is possible to disable warnings associated with functions deprecated due to safety issue using _CRT_SECURE_NO_WARNINGS. It is also possible to replace some of the functions with their safer counterpart using _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES. However, does anybody know if both can be used simultaneously. That is, if I first specify _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES and then _CRT_SECURE_NO_WARNINGS, will those functions that can be replaced be replaced and for remaining cases the warnings are suppressed. I'm not sure how to test this, because if I add both, all warnings will effectively be suppressed, but I don't know if it is only due to the second flag.


Solution

  • Yes, you can use both, and they are doing exactly what you've expected.

    You can take a look at crtdefs.h header file. In case you define _CRT_SECURE_NO_WARNINGS it simply doesn't generate a warning in place of _CRT_INSECURE_DEPRECATE references.

    The _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES controls other macros, like __DEFINE_CPP_OVERLOAD_STANDARD_FUNC_ ... and alike.