5

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?

Weeedooo
  • 501
  • 8
  • 25

6 Answers6

6

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
wallyk
  • 56,922
  • 16
  • 83
  • 148
4

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

Victor
  • 761
  • 8
  • 7
1

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.

user7860670
  • 35,849
  • 4
  • 58
  • 84
1

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.

Ski
  • 31
  • 5
0

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.

KulaGGin
  • 943
  • 2
  • 12
  • 27
0

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.

dmihailescu
  • 1,625
  • 17
  • 15