From c23dcdc88a6a39012b16e7f17b20381d393e2351 Mon Sep 17 00:00:00 2001 From: Scott Graham Date: Mon, 15 Dec 2014 15:55:41 -0800 Subject: [PATCH] win: set CXX_LIBRARY_VERSION to 2011 Unfortunately VS2013's support of C++11 is partial. It supports the extended union definition, but does not fully support constexpr. So, update some locations where CXX_LIBRARY_VERSION is used where toolchain support is lacking. It works correctly in the locations where std::is_standard_layout is used. R=mark@chromium.org BUG=crashpad:1 Review URL: https://codereview.chromium.org/803273002 --- util/stdlib/cxx.h | 13 +++++++++++++ util/stdlib/string_number_conversion.cc | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/util/stdlib/cxx.h b/util/stdlib/cxx.h index 261a6c11..0e1cc435 100644 --- a/util/stdlib/cxx.h +++ b/util/stdlib/cxx.h @@ -15,6 +15,15 @@ #ifndef CRASHPAD_UTIL_STDLIB_CXX_H_ #define CRASHPAD_UTIL_STDLIB_CXX_H_ +#include "build/build_config.h" + +#if defined(COMPILER_MSVC) + +#define CXX_LIBRARY_VERSION 2011 +#define CXX_LIBRARY_HAS_CONSTEXPR 0 + +#else // !COMPILER_MSVC + // doesn’t do very much, and under libc++, it will cause the // _LIBCPP_VERSION macro to be defined properly. Under libstdc++, it doesn’t // cause __GLIBCXX__ to be defined, but if _LIBCPP_VERSION isn’t defined after @@ -50,8 +59,12 @@ __GLIBCXX__ != 20120702ul) || /* GCC 4.5.4 */ \ (defined(_LIBCPP_VERSION))) #define CXX_LIBRARY_VERSION 2011 +#define CXX_LIBRARY_HAS_CONSTEXPR 1 #else #define CXX_LIBRARY_VERSION 2003 +#define CXX_LIBRARY_HAS_CONSTEXPR 0 #endif +#endif // COMPILER_MSVC + #endif // CRASHPAD_UTIL_STDLIB_CXX_H_ diff --git a/util/stdlib/string_number_conversion.cc b/util/stdlib/string_number_conversion.cc index a7c7d519..de8b5788 100644 --- a/util/stdlib/string_number_conversion.cc +++ b/util/stdlib/string_number_conversion.cc @@ -29,7 +29,7 @@ // the std::numeric_limits<>::min() and max() functions will not be marked as // constexpr, and thus won’t be usable with C++11’s static_assert(). In that // case, a run-time CHECK() will have to do. -#if CXX_LIBRARY_VERSION >= 2011 +#if CXX_LIBRARY_VERSION >= 2011 && CXX_LIBRARY_HAS_CONSTEXPR #define CONSTEXPR_STATIC_ASSERT(condition, message) \ static_assert(condition, message) #else