Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does "use -D_SCL_SECURE_NO_WARNINGS" mean?

I've got an error trying to compile my curve compression program, error no C4996, function call with parameters may be unsafe. It's telling me to use the above. The error is coming from xutility header file, which I've never laid eyes on before. is this a flag I have to input into a console? There is literally no reference to it online...

like image 367
Robbie Cooper Avatar asked Jul 30 '14 20:07

Robbie Cooper


People also ask

What does #define _crt_secure_no_warnings do?

_CRT_SECURE_NO_WARNINGS means you don't want the compiler to suggest the secure versions of the library functions, e.g. scanf_s when you use scanf .

How do you turn off warnings in C++?

To disable a set of warnings for a given piece of code, you have to start with a “push” pre-processor instruction, then with a disabling instruction for each of the warning you want to suppress, and finish with a “pop” pre-processor instruction.


3 Answers

-D is a command line compiler flag which causes the rest of the text to be treated as if there was a #define in your code.

In solution explorer, right click the project, select "properties". The project property page will open. Expand the ">C/C++" entry in the tree on the left and select "Preprocessor" under that. The top entry in the right pane should be "Preprocessor Definitions". In that edit box, add _SCL_SECURE_NO_WARNINGS, separating it from the other entries with a ;

like image 73
Rob K Avatar answered Sep 22 '22 16:09

Rob K


I'd like to also add that if you want to use

#define _SCL_SECURE_NO_WARNINGS

directly in your code, you have to place it before including headers. Or you can use

#pragma warning(disable:4996)
like image 20
Kaaf Avatar answered Sep 20 '22 16:09

Kaaf


-D means "define a macro", in this case _SCL_SECURE_NO_WARNINGS. Which mean somewhere in the code there's a

#if defined(_SCL_SECURE_NO_WARNINGS)

line. If you want to do this from inside VS, go to the project's properties page, and under one fo the tabs there should be a spot to add new defines. There should already be some listed (like DEBUG). Add _SCL_SECURE_NO_WARNINGS there.

like image 28
James Curran Avatar answered Sep 21 '22 16:09

James Curran