• Advertisement
Sign in to follow this  

Solved - VC++ won't stop bitching!

This topic is 3776 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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 #define _CRT_SECURE_NO_WARNINGS 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? Thanks, TLAK EDIT: Solved! [Edited by - TLAK1001 on September 23, 2007 11:41:25 AM]

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
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.

EDIT: damn, mmelson was a few seconds faster.

Share this post


Link to post
Share on other sites
The bigger question is why he is "...aware that the _s versions are more secure..." but chooses not to use them anyways.

If you know they're more secure, etc...why not just use them? The warning is there for a reason.

Cheers!

Share this post


Link to post
Share on other sites
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.

Thanks guys!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement