When I try to use functions like fopen, fscanf, or strcpy, VC++ tells me
c:\documents and settings\tyler\my documents\my code\c++\vise\script.cpp(82) : warning 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.
The online help says "to define _CRT_SECURE_NO_WARNINGS". When I write
in my code, I still get the same stupid warning. How do I make it go away? (hard code is much appreciated) I am aware that the _s versions are more secure, but I don't want to use them. How do I disable the warning and go on using the unsecure functions?
[Edited by - TLAK1001 on September 23, 2007 11:41:25 AM]
In order to disable the warnings project-wide, you can define it in the "Preprocessor" section under "C/C++" in the project settings (you have to it for both Debug and Release configurations). However, make sure that you really don't want to use the safe versions of these deprecated function before you do this, because you won't ever see the warnings again.
You shouldn't define _CRT_SECURE_NO_WARNINGS in any header or source files! You should instead go into the project settings and list it in "Preprocessor Defines" under "C/C++" -> "Preprocessor". Don't forget to do this for both release and debug.
Walsh, This is very true, but I'm using a massive header from someone else and don't have the time to fix the hundreds of instances. The code makes sure that everything is safe already, so there's no point.
Melson, Added "_CRT_SECURE_NO_WARNINGS" where you said, life is good. Thanks for the menu walk through of how to get there as well. Very helpful.