?
Solved

Unable to resolve _CRT_SECURE_NO_WARNINGS

Posted on 2015-02-09
3
Medium Priority
?
178 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 35

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 35

Accepted Solution

by:
sarabande earned 2000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
Suggested Courses

764 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