Weeedooo
Weeedooo

Reputation: 557

VS 2017 Command line error D8004

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?

Upvotes: 6

Views: 9581

Answers (6)

dmihailescu
dmihailescu

Reputation: 1643

if you don't want to change the project settings, you can add #define _SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING 1 to the stdafx.h if you have one. It worked for me.

Upvotes: 0

KulaGGin
KulaGGin

Reputation: 1249

I fixed this error by going into Project Properties > Configuration Properties > C/C++ > Preprocessor > Preprocessor Definitions and adding _SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING to the preprocessor definitions: enter image description here

After this gtest was finally built successfully.

Adding #define _SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING 1 at the top of the file and in the Additional Preprocesor Definitions when I click on the project didn't help.

Upvotes: 0

Victor
Victor

Reputation: 781

Please follow the following steps:

  1. Click View in the tool baar.

  2. Select properties.. at the bottom.

3.Select c/c++ -> Preprocessor.

4.Set Preprocessor Definitions as _SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING

Upvotes: 5

Ski
Ski

Reputation: 31

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.

Upvotes: 1

user7860670
user7860670

Reputation: 37598

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.

Upvotes: 2

wallyk
wallyk

Reputation: 57784

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

Upvotes: 6

Related Questions