Solved

Unable to resolve _CRT_SECURE_NO_WARNINGS

Posted on 2015-02-09
3
135 Views
Last Modified: 2015-02-20
I've appended _CRT_SECURE_NO_WARNINGS to the list of Preprocessor Definitions under the  'C/C++' Preprocessor', but the compiler continues to flag the traditional string function strcat as being errors.

I've read several technical documents which indicated that the compiler will flag a warning, but in my case it is being flagged as an error.

Can someone tell me what I'm doing wrong?  Thank you.

PS - The following is the exact string found in my Preprocessor Definitions input box:

WIN32;NDEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_MESSAGES;%(PreprocessorDefinitions);USE_STANDARD_FILE_FUNCTIONS
0
Comment
Question by:CarmenMTorres
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 34

Expert Comment

by:sarabande
ID: 40600281
I had the same issue and helped me out by adding

#pragma warning(disable: 4996)

Open in new window


to the source where the warning occurred.

later I found out that the following preprocessor macro

#define _CRT_SECURE_NO_DEPRECATE

Open in new window


also worked. you either could add the definition above the code or use the preprocessor definition in the c++ configuration properties.

Sara
0
 

Author Comment

by:CarmenMTorres
ID: 40600762
If I include the "#define _CRT_SECURE_NO_DEPRECATE" statement in the source code, the compiler complains stating that I'm trying to redefine it because I have it also defined in the Preprocessor Definition area.

I'm still unable to resolve the error messages.
0
 
LVL 34

Accepted Solution

by:
sarabande earned 500 total points
ID: 40601163
which indicated that the compiler will flag a warning, but in my case it is being flagged as an error.
it seems that in vs2013 strcpy, strcat, ... and others have turned from 'deprecated' to 'disallowed'. that would explain that you got an error instead of warning C4996 as I got in vs2010.

because of that also the #pragma warning could not work.

that means you would need to use strcpy_s, strcat_s instead which require an additional size argument to prevent from buffer overflow. alternatively you could provide some wrapper functions and put them into a .c source. you may decide whether it is worth the efforts. in the last years I used the _s versions of the string functions for non-portable code and in a few cases they have helped me to find a bug.

Sara
0

Featured Post

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question