diff options
author | Thomas Van Lenten <thomasvl@google.com> | 2015-12-08 17:21:43 -0500 |
---|---|---|
committer | Thomas Van Lenten <thomasvl@google.com> | 2015-12-08 17:21:43 -0500 |
commit | 46be1d06f5f65ee38a54e1ea7743b1d0a4580df9 (patch) | |
tree | 753499e18da89d7facf5417909c10037f148ef05 | |
parent | 9bd74b7f25b45b253f46025d7300a17df58d213f (diff) | |
parent | 52b8d3fe784cb83a6398bb35fd4cf89b92e46c21 (diff) | |
download | protobuf-46be1d06f5f65ee38a54e1ea7743b1d0a4580df9.tar.gz protobuf-46be1d06f5f65ee38a54e1ea7743b1d0a4580df9.tar.bz2 protobuf-46be1d06f5f65ee38a54e1ea7743b1d0a4580df9.zip |
Merge pull request #1034 from thomasvl/static_assert_fix
Use compiler provided static assert and avoid tripping unused-local-typedef warnings.
-rw-r--r-- | objectivec/GPBMessage.m | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/objectivec/GPBMessage.m b/objectivec/GPBMessage.m index caef584c..d9080c3f 100644 --- a/objectivec/GPBMessage.m +++ b/objectivec/GPBMessage.m @@ -55,10 +55,15 @@ NSString *const GPBExceptionMessageKey = static NSString *const kGPBDataCoderKey = @"GPBData"; #ifndef _GPBCompileAssert -#define _GPBCompileAssertSymbolInner(line, msg) _GPBCompileAssert ## line ## __ ## msg -#define _GPBCompileAssertSymbol(line, msg) _GPBCompileAssertSymbolInner(line, msg) -#define _GPBCompileAssert(test, msg) \ - typedef char _GPBCompileAssertSymbol(__LINE__, msg) [ ((test) ? 1 : -1) ] + #if __has_feature(c_static_assert) || __has_extension(c_static_assert) + #define _GPBCompileAssert(test, msg) _Static_assert((test), #msg) + #else + // Pre-Xcode 7 support. + #define _GPBCompileAssertSymbolInner(line, msg) _GPBCompileAssert ## line ## __ ## msg + #define _GPBCompileAssertSymbol(line, msg) _GPBCompileAssertSymbolInner(line, msg) + #define _GPBCompileAssert(test, msg) \ + typedef char _GPBCompileAssertSymbol(__LINE__, msg) [ ((test) ? 1 : -1) ] + #endif // __has_feature(c_static_assert) || __has_extension(c_static_assert) #endif // _GPBCompileAssert // |