I have some C++ code that uses some version of Google's GTest framework. This code used to compile fine 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 some compiler option needed to use std::tr1 in VS2017?
One option is to re-enable TR1; do this by defining the macro
_HAS_TR1_NAMESPACE, as briefly mentioned in this blog article. If you're using an MSBuild project then this is best done by way of your project's Preprocessor Definitions setting; or if you're using a precompiled header, by defining it at the top of said PCH.A better option is to inform GTest that your compiler supports C++11 by defining the macro
GTEST_LANG_CXX11to1before including any GTest headers; then it will usestd::tuplerather thanstd::tr1::tuple*. (GTest's C++11-detection logic is__cplusplus-oriented, which VC++ has not yet updated despite being mostly C++11 and C++14 compliant. I would say this is a bug in GTest since it supports VC++ elsewhere throughout the configuration logic.)* Not to mention the other C++11 features, which is why this is by far the better option ;-]