diff options
author | kosak@google.com <kosak@google.com@861a406c-534a-0410-8894-cb66d6ee9925> | 2014-11-17 00:27:28 +0000 |
---|---|---|
committer | kosak@google.com <kosak@google.com@861a406c-534a-0410-8894-cb66d6ee9925> | 2014-11-17 00:27:28 +0000 |
commit | cf04de739d74417ebf73c34c8ea86d53bbe1f893 (patch) | |
tree | d7a1c1fd4d81941178c37684443220f94e668db5 /include | |
parent | ad9f2263a15f0df8738ab64d49a5277d6d7d036e (diff) | |
download | googletest-cf04de739d74417ebf73c34c8ea86d53bbe1f893.tar.gz |
Distinguish between C++11 language and library support for std::function, std::begin, std::end, and std::move in gtest and gmock.
git-svn-id: http://googletest.googlecode.com/svn/trunk@694 861a406c-534a-0410-8894-cb66d6ee9925
Diffstat (limited to 'include')
-rw-r--r-- | include/gtest/internal/gtest-port.h | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/include/gtest/internal/gtest-port.h b/include/gtest/internal/gtest-port.h index f376dfa..17220a5 100644 --- a/include/gtest/internal/gtest-port.h +++ b/include/gtest/internal/gtest-port.h @@ -377,12 +377,34 @@ # endif #endif -// C++11 specifies that <initializer_list> provides std::initializer_list. Use -// that if gtest is used in C++11 mode and libstdc++ isn't very old (binaries -// targeting OS X 10.6 can build with clang but need to use gcc4.2's -// libstdc++). -#if GTEST_LANG_CXX11 && (!defined(__GLIBCXX__) || __GLIBCXX__ > 20110325) +// Distinct from C++11 language support, some environments don't provide +// proper C++11 library support. Notably, it's possible to build in +// C++11 mode when targeting Mac OS X 10.6, which has an old libstdc++ +// with no C++11 support. +// +// libstdc++ has sufficient C++11 support as of GCC 4.6.0, __GLIBCXX__ +// 20110325, but maintenance releases in the 4.4 and 4.5 series followed +// this date, so check for those versions by their date stamps. +// https://gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html#abi.versioning +#if GTEST_LANG_CXX11 && \ + (!defined(__GLIBCXX__) || ( \ + __GLIBCXX__ >= 20110325ul && /* GCC >= 4.6.0 */ \ + /* Blacklist of patch releases of older branches: */ \ + __GLIBCXX__ != 20110416ul && /* GCC 4.4.6 */ \ + __GLIBCXX__ != 20120313ul && /* GCC 4.4.7 */ \ + __GLIBCXX__ != 20110428ul && /* GCC 4.5.3 */ \ + __GLIBCXX__ != 20120702ul)) /* GCC 4.5.4 */ +# define GTEST_STDLIB_CXX11 1 +#endif + +// Only use C++11 library features if the library provides them. +#if GTEST_STDLIB_CXX11 +# define GTEST_HAS_STD_BEGIN_AND_END_ 1 +# define GTEST_HAS_STD_FORWARD_LIST_ 1 +# define GTEST_HAS_STD_FUNCTION_ 1 # define GTEST_HAS_STD_INITIALIZER_LIST_ 1 +# define GTEST_HAS_STD_MOVE_ 1 +# define GTEST_HAS_STD_UNIQUE_PTR_ 1 #endif // C++11 specifies that <tuple> provides std::tuple. @@ -883,7 +905,7 @@ using ::std::tuple_size; # define GTEST_MUST_USE_RESULT_ #endif // __GNUC__ && (GTEST_GCC_VER_ >= 30400) && !COMPILER_ICC -#if GTEST_LANG_CXX11 +#if GTEST_HAS_STD_MOVE_ # define GTEST_MOVE_(x) ::std::move(x) // NOLINT #else # define GTEST_MOVE_(x) x |