Solved

Unable to resolve _CRT_SECURE_NO_WARNINGS

Posted on 2015-02-09
3
96 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 32

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 32

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

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…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

758 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now