问题
I'm out of options, I'm trying to work with GoogleTest on Visual Studio 2017 Community but it gives me a lot of
warning C4996: 'std::tr1': warning STL4002: The non-Standard std::tr1 namespace and TR1-only machinery are deprecated and will be REMOVED. You can define _SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING to acknowledge that you have received this warning.
I want to supress it, so I go under my Project Properties -> C/C++ -> Advanced -> Supress Specific Warnings and I try
/wd4996
/wdSTL4002,
/wd4996;
/wdC4996
/wd[4996]...
etc, I honestly tried every possible combination and it throws me
2>cl : Command line error D8004: '/wd' requires an argument
Could someone send me exactly what I need to write there to supress this?
回答1:
According to the error message, you can add a #define
equivalent to the command line:
/D:_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING
That is the equivalent of inserting before the first line of the source files
#define _SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING 1
回答2:
Please follow the following steps:
Click View in the tool baar.
Select properties.. at the bottom.
3.Select c/c++ -> Preprocessor.
4.Set Preprocessor Definitions as _SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING
回答3:
I know this has an answer already, but to answer your question specifically, if you simply add 4996, as opposed to /wd[4996] (or any other variation of that).
All you need to add is 4996.
回答4:
Silencing warnings is never a good option. In this case warning about tr1
seems to arise from incorrect project configuration. You can try defining GTEST_LANG_CXX11
to make gtest use stuff from std
namespace or track origins of those warnings and figure out why are they still issued.
来源:https://stackoverflow.com/questions/48091421/vs-2017-command-line-error-d8004