Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting an error "fopen': This function or variable may be unsafe." when compling [duplicate]

Tags:

c++

opencv

fopen

I'm receiving this error when compiling:

'fopen': This function or variable may be unsafe.  Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. 

I'm new to C++ and open CV, therefore please help me to get rid of this error.

Thanks

void _setDestination(const char* name) {     if (name==NULL) {         stream = stdout;     }     else {         stream = fopen(name,"w");         if (stream == NULL) {             stream = stdout;         }     } } 
like image 336
SeverusSwan Avatar asked Feb 19 '14 06:02

SeverusSwan


1 Answers

This is not an error, it is a warning from your Microsoft compiler.

Select your project and click "Properties" in the context menu.

In the dialog, chose Configuration Properties -> C/C++ -> Preprocessor

In the field PreprocessorDefinitions add ;_CRT_SECURE_NO_WARNINGS to turn those warnings off.

like image 64
nvoigt Avatar answered Sep 21 '22 20:09

nvoigt