Disabling Warnings generated via _CRT_SECURE_NO_DEPRECATE
If you don't want to pollute your source code (after all this warning presents only with Microsoft compiler), add _CRT_SECURE_NO_WARNINGS
symbol to your project settings via "Project"->"Properties"->"Configuration properties"->"C/C++"->"Preprocessor"->"Preprocessor definitions".
Also you can define it just before you include a header file which generates this warning.
You should add something like this
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif
And just a small remark, make sure you understand what this warning stands for, and maybe, if you don't intend to use other compilers than MSVC, consider using safer version of functions i.e. strcpy_s instead of strcpy.
How to use _CRT_SECURE_NO_WARNINGS
Add by
Configuration Properties>>C/C++>>Preporocessor>>Preprocessor
Definitions>> _CRT_SECURE_NO_WARNINGS
CRT deprecation warnings
Yes, you can use both, and they are doing exactly what you've expected.
You can take a look at crtdefs.h
header file. In case you define _CRT_SECURE_NO_WARNINGS
it simply doesn't generate a warning in place of _CRT_INSECURE_DEPRECATE
references.
The _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES
controls other macros, like __DEFINE_CPP_OVERLOAD_STANDARD_FUNC_ ...
and alike.
_CRT_SECURE_NO_DEPRECATE globally?
I'm not aware of a global option like an environment variable. And you really don't want that anyway.
I know of 2 methods to easily spread configurations including preprocessor definitions:
- Create a header file with your favorite macro/types/whatever.
- Create
a prop file and have your project reference it. This is more complex.
fopen deprecated warning
It looks like Microsoft has deprecated lots of calls which use buffers to improve code security. However, the solutions they're providing aren't portable. Anyway, if you aren't interested in using the secure version of their calls (like fopen_s), you need to place a definition of _CRT_SECURE_NO_DEPRECATE before your included header files. For example:
#define _CRT_SECURE_NO_DEPRECATE
#include <stdio.h>
The preprocessor directive can also be added to your project settings to effect it on all the files under the project. To do this add _CRT_SECURE_NO_DEPRECATE to Project Properties -> Configuration Properties -> C/C++ -> Preprocessor -> Preprocessor Definitions.
Can I prevent nested deprecated method calls from raising warnings?
Speaking without proof, but maybe a macro could help here. Easier to show than to explain:
MyClass.h
---------
#ifndef MYCLASS_DEPRECATE
#define MYCLASS_DEPRECATE [Obsolete]
#endif
class MyClass
{
MYCLASS_DEPRECATE void OldMethodHelper();
...
}
MyClass.cpp
-----------
#define MYCLASS_DEPRECATE
#include "MyClass.h"
// The rest of the code
Related Topics
Is Maximum_Wait_Objects Really 64
When Would You Use an Array Rather Than a Vector/String
Opencv 2.4.3 iOS Framework Compiler Trouble Recognising Some C++ Headers
Multiple Inheritance: Unexpected Result After Cast from Void * to 2Nd Base Class
Strange "Unsigned Long Long Int" Behaviour
How to Read Frames from Videocapture from Secondary Webcam with Opencv
Qt Moc with Implementations Inside of Header Files
What's the Difference Between Type(Myvar) and (Type)Myvar
How to Find the Current Directory
Portable End of Line (Newline)
Erasing Vector::End from Vector
Getting the Size of a C++ Function