Solved

Unable to resolve _CRT_SECURE_NO_WARNINGS

Posted on 2015-02-09
3
123 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
  • 2
3 Comments
 
LVL 33

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 33

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

785 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