diff options
author | Jisi Liu <liujisi@google.com> | 2015-07-20 17:36:00 -0700 |
---|---|---|
committer | Jisi Liu <liujisi@google.com> | 2015-07-20 17:36:00 -0700 |
commit | d119a275495b7dcc9c389c9c650ebd83de265511 (patch) | |
tree | 12cff947d8e26d1ce6443dde36f9e9fcfb25d1cf | |
parent | aba42edd8c3c5ae4edeebdacd1a3b4192bd5550f (diff) | |
parent | 56a90a2081379a5286edf0eea70aa2000e26c7f9 (diff) | |
download | protobuf-d119a275495b7dcc9c389c9c650ebd83de265511.tar.gz protobuf-d119a275495b7dcc9c389c9c650ebd83de265511.tar.bz2 protobuf-d119a275495b7dcc9c389c9c650ebd83de265511.zip |
Merge pull request #621 from nico/staticass
Let GOOGLE_COMPILE_ASSERT use static_assert if available.
-rw-r--r-- | src/google/protobuf/stubs/macros.h | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/google/protobuf/stubs/macros.h b/src/google/protobuf/stubs/macros.h index eb38268e..0e9a9ec1 100644 --- a/src/google/protobuf/stubs/macros.h +++ b/src/google/protobuf/stubs/macros.h @@ -113,12 +113,13 @@ struct CompileAssert { } // namespace internal #undef GOOGLE_COMPILE_ASSERT +#if __cplusplus >= 201103L +#define GOOGLE_COMPILE_ASSERT(expr, msg) static_assert(expr, #msg) +#else #define GOOGLE_COMPILE_ASSERT(expr, msg) \ ::google::protobuf::internal::CompileAssert<(bool(expr))> \ msg[bool(expr) ? 1 : -1]; \ (void)msg - - // Implementation details of COMPILE_ASSERT: // // - COMPILE_ASSERT works by defining an array type that has -1 @@ -159,6 +160,7 @@ struct CompileAssert { // // This is to avoid running into a bug in MS VC 7.1, which // causes ((0.0) ? 1 : -1) to incorrectly evaluate to 1. +#endif // __cplusplus >= 201103L } // namespace protobuf } // namespace google |