none
_CRT_SECURE_NO_WARNINGS vs. _CRT_SECURE_NO_DEPRECATE

    Question

  • We have a app that we have converted from VC6 -> VS2005. We added _CRT_SECURE_NO_WARNINGS to the preprocessor to eliminate the warnings for sprinf, strcpy, etc. We recently added another developer and on his machine he gets the warnings again and it says to try using _CRT_SECURE_NO_DEPRECATE.

     

    Why would one machine machine want _CRT_SECURE_NO_DEPRECATE and the other _CRT_SECURE_NO_WARNINGS? Both are using VS2005 Sp1.

     

    Thanks

     

    Terry

    Wednesday, October 03, 2007 7:21 PM

Answers

  •  DoctorSlicer wrote:
    Why would one machine machine want _CRT_SECURE_NO_DEPRECATE and the other _CRT_SECURE_NO_WARNINGS? Both are using VS2005 Sp1.

     

    Take a look at the version of the file crtdefs.h being used on each system. 

     

    In an older copy of crtdefs.h at around line 316 the macro '_CRT_INSECURE_DEPRECATE' is defined.  What it is defined to be is controlled by the test '#ifdef _CRT_SECURE_NO_DEPRECATE' and the text message associated with the macro is "This function or variable may be unsafe. Consider using " #_Replacement " instead. To disable deprecation, use _CRT_SECURE_NO_DEPRECATE. See online help for details."

     

    In a newer copy of crtdefs.h at around line 339 the same macro is defined only this time what is defined is controlled by the test '#ifdef _CRT_SECURE_NO_WARNINGS' and the text message associated with the macro is "This function or variable may be unsafe. Consider using " #_Replacement " instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details."

     

    Also in the newer version of crtdefs.h is the following code

     

    Code Block

     

     #if defined(_CRT_SECURE_NO_DEPRECATE) && !defined(_CRT_SECURE_NO_WARNINGS)

     #define _CRT_SECURE_NO_WARNINGS

     #endif

     

     

    I would guess that originally the macro to control these warnings was called _CRT_SECURE_NO_DEPRECATE and that later the macro was renamed _CRT_SECURE_NO_WARNINGS. 

     

    Your new developer seems to have the older version of crtdefs.h on his system, or perhaps has both versions of crtdefs.h on his system but has Tools | Options | VC++ Directories settings that cause the wrong crtdefs.h file to be loaded. 

    Wednesday, October 03, 2007 10:30 PM
    Moderator

All replies

  • The font was somehow messed up in the original question but it is fixed now.

    Wednesday, October 03, 2007 9:21 PM
  •  DoctorSlicer wrote:
    Why would one machine machine want _CRT_SECURE_NO_DEPRECATE and the other _CRT_SECURE_NO_WARNINGS? Both are using VS2005 Sp1.

     

    Take a look at the version of the file crtdefs.h being used on each system. 

     

    In an older copy of crtdefs.h at around line 316 the macro '_CRT_INSECURE_DEPRECATE' is defined.  What it is defined to be is controlled by the test '#ifdef _CRT_SECURE_NO_DEPRECATE' and the text message associated with the macro is "This function or variable may be unsafe. Consider using " #_Replacement " instead. To disable deprecation, use _CRT_SECURE_NO_DEPRECATE. See online help for details."

     

    In a newer copy of crtdefs.h at around line 339 the same macro is defined only this time what is defined is controlled by the test '#ifdef _CRT_SECURE_NO_WARNINGS' and the text message associated with the macro is "This function or variable may be unsafe. Consider using " #_Replacement " instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details."

     

    Also in the newer version of crtdefs.h is the following code

     

    Code Block

     

     #if defined(_CRT_SECURE_NO_DEPRECATE) && !defined(_CRT_SECURE_NO_WARNINGS)

     #define _CRT_SECURE_NO_WARNINGS

     #endif

     

     

    I would guess that originally the macro to control these warnings was called _CRT_SECURE_NO_DEPRECATE and that later the macro was renamed _CRT_SECURE_NO_WARNINGS. 

     

    Your new developer seems to have the older version of crtdefs.h on his system, or perhaps has both versions of crtdefs.h on his system but has Tools | Options | VC++ Directories settings that cause the wrong crtdefs.h file to be loaded. 

    Wednesday, October 03, 2007 10:30 PM
    Moderator
  • Sorry about the font. I selected Arial 10pt but it posted it in that super large font.
    Thursday, October 04, 2007 12:17 AM
  • Thanks for the help. There was an older version installed that was not removed properly when installing VS2005. VS2005 was uninstalled and then reinstalled which corrected the problem.
    Thursday, October 04, 2007 12:18 AM
  • I am sorry for overreacting. I assume the forum software messed up again. That happens.

    Thursday, October 04, 2007 12:34 AM