C++ “使用-D_SCL_SECURE_NO_WARNINGS”是什么意思?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25046829/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What does "use -D_SCL_SECURE_NO_WARNINGS" mean?
提问by Robbie Cooper
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...
我在尝试编译我的曲线压缩程序时遇到错误,错误号为 C4996,带参数的函数调用可能不安全。它告诉我使用上面的。错误来自 xutility 头文件,我以前从未关注过它。这是我必须输入到控制台的标志吗?网上几乎没有提到它...
回答by Rob K
-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.
-D 是一个命令行编译器标志,它使文本的其余部分被视为代码中存在 #define。
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 ;
在解决方案资源管理器中,右键单击项目,选择“属性”。项目属性页面将打开。展开左侧树中的“>C/C++”条目并选择其下的“预处理器”。右窗格中的顶部条目应该是“预处理器定义”。在该编辑框中,添加_SCL_SECURE_NO_WARNINGS,用 ; 将其与其他条目分开。
回答by Kaaf
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)
回答by James Curran
-D
means "define a macro", in this case _SCL_SECURE_NO_WARNINGS
. Which mean somewhere in the code there's a
-D
意思是“定义一个宏”,在这种情况下_SCL_SECURE_NO_WARNINGS
。这意味着代码中的某处有一个
#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.
线。如果您想从 VS 内部执行此操作,请转到项目的属性页面,在选项卡下应该有一个位置可以添加新定义。应该已经列出了一些(如DEBUG
)。添加到_SCL_SECURE_NO_WARNINGS
那里。
回答by Anand Choubey
-D is compiler flag or a macro like you were defined in your source code.
-D 是编译器标志或像您在源代码中定义的宏。
-D_SCL_SECURE_NO_WARNINGS defines _SCL_SECURE_NO_WARNINGS macro.
-D_SCL_SECURE_NO_WARNINGS 定义了 _SCL_SECURE_NO_WARNINGS 宏。
Please look at below link for more details on _SCL_SECURE_NO_WARNINGS macro. https://devblogs.microsoft.com/cppblog/why-am-i-getting-these-_scl_secure_no_warnings-messages/
请查看以下链接以了解有关 _SCL_SECURE_NO_WARNINGS 宏的更多详细信息。 https://devblogs.microsoft.com/cppblog/why-am-i-getting-these-_scl_secure_no_warnings-messages/