[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 282
  • Last Modified:

Unable to resolve _CRT_SECURE_NO_WARNINGS

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
CarmenMTorres
Asked:
CarmenMTorres
  • 2
1 Solution
 
sarabandeCommented:
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
 
CarmenMTorresAuthor Commented:
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
 
sarabandeCommented:
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now