Std :: tr1 with visual studio 2017

I have C ++ code that uses some version of the Google GTest system. This code is used to compile with Visual Studio 2015. I just upgraded to VS2017 and now I get a bunch of errors like this:

error C2039: 'tr1': is not a member of 'std' error C3083: 'tr1': the symbol to the left of a '::' must be a type 

Is there some kind of compiler option for using std :: tr1 in VS2017?

+5
source share
1 answer

One option is to re-enable TR1; do this by defining the _HAS_TR1_NAMESPACE macro, as summarized in this blog article . If you use the MSBuild project, this is best done according to your project, setting up the preprocessor parameters ; or if you use a precompiled header by defining it at the top of the specified PCH.

The best option is to inform GTest that your compiler supports C ++ 11 by defining the macro GTEST_LANG_CXX11 to 1 before including any GTest headers; then it will use std::tuple , not std::tr1::tuple *. ( The detection logic for GTest C ++ 11 is __cplusplus oriented, which VC ++ has not yet updated, despite the fact that it is mainly C ++ 11 and C ++ 14. I would say that this is a bug in GTest, since it supports VC ++ elsewhere throughout the configuration logic.)

* Not to mention the other features of C ++ 11, so this is the best option: -]

+6
source

Source: https://habr.com/ru/post/1265583/


All Articles