Jump to content

  • Log In with Google      Sign In   
  • Create Account

We need your help!

We need 7 developers from Canada and 18 more from Australia to help us complete a research survey.

Support our site by taking a quick sponsored survey and win a chance at a $50 Amazon gift card. Click here to get started!


Solved - VC++ won't stop bitching!


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 TLAK1001   Members   -  Reputation: 122

Like
0Likes
Like

Posted 23 September 2007 - 05:13 AM

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]

Sponsor:

#2 Oluseyi   Staff Emeritus   -  Reputation: 2067

Like
0Likes
Like

Posted 23 September 2007 - 05:16 AM

Where do you define _CRT_SECURE_NO_WARNINGS? You should define it before you include the relevant headers - might as well place it at the very top of your implementation file, script.cpp.

#3 mmelson   Members   -  Reputation: 232

Like
0Likes
Like

Posted 23 September 2007 - 05:21 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.

#4 Trenki   Members   -  Reputation: 345

Like
0Likes
Like

Posted 23 September 2007 - 05:22 AM

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.

#5 JWalsh   Moderators   -  Reputation: 473

Like
0Likes
Like

Posted 23 September 2007 - 05:28 AM

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!
Jeromy Walsh
Sr. Tools & Engine Programmer | Software Engineer
Microsoft Windows Phone Team
Chronicles of Elyria (An In-development MMORPG)
GameDevelopedia.com - Blog & Tutorials
GDNet Mentoring: XNA Workshop | C# Workshop | C++ Workshop
"The question is not how far, the question is do you possess the constitution, the depth of faith, to go as far as is needed?" - Il Duche, Boondock Saints

#6 TLAK1001   Members   -  Reputation: 122

Like
0Likes
Like

Posted 23 September 2007 - 05:40 AM

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!




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS