diff options
author | Robert Edmonds <edmonds@debian.org> | 2014-09-18 18:03:12 -0400 |
---|---|---|
committer | Robert Edmonds <edmonds@debian.org> | 2014-09-18 18:36:00 -0400 |
commit | 7432af823a45b954a8bc6018cdc7fa4c1f8fd16f (patch) | |
tree | e20e6ae0ecc3068711f933132ecb1d901f7f6691 /src | |
parent | 5c8ab2cbb3b88c67623ce1ca1c9d45eb0b47e7ab (diff) | |
download | protobuf-7432af823a45b954a8bc6018cdc7fa4c1f8fd16f.tar.gz protobuf-7432af823a45b954a8bc6018cdc7fa4c1f8fd16f.tar.bz2 protobuf-7432af823a45b954a8bc6018cdc7fa4c1f8fd16f.zip |
Fix atomicops build failure on non-Clang
We cannot use Clang's __has_extension macro unless we really are
compiling on Clang, which means we cannot use this expression:
#if (defined(__clang__) && __has_extension(c_atomic)))
// ...
#endif
On GCC, this generates the following errors:
In file included from ./google/protobuf/stubs/atomicops.h:59:0,
from google/protobuf/stubs/atomicops_internals_x86_gcc.cc:36:
./google/protobuf/stubs/platform_macros.h:67:41: error: missing binary operator before token "("
(defined(__clang__) && __has_extension(c_atomic)))
^
In file included from google/protobuf/stubs/atomicops_internals_x86_gcc.cc:36:0:
./google/protobuf/stubs/atomicops.h:196:40: error: missing binary operator before token "("
(defined(__clang__) && __has_extension(c_atomic))
^
Instead, we have to protect the __has_extension expression by only
executing it when __clang__ is defined:
#if defined(__clang__)
# if __has_extension(c_atomic)
// ...
# endif
#endif
Diffstat (limited to 'src')
-rw-r--r-- | src/google/protobuf/stubs/atomicops.h | 9 | ||||
-rw-r--r-- | src/google/protobuf/stubs/platform_macros.h | 18 |
2 files changed, 20 insertions, 7 deletions
diff --git a/src/google/protobuf/stubs/atomicops.h b/src/google/protobuf/stubs/atomicops.h index 8ddd2508..17b7be7f 100644 --- a/src/google/protobuf/stubs/atomicops.h +++ b/src/google/protobuf/stubs/atomicops.h @@ -192,9 +192,14 @@ GOOGLE_PROTOBUF_ATOMICOPS_ERROR #include <google/protobuf/stubs/atomicops_internals_mips_gcc.h> #elif defined(__native_client__) #include <google/protobuf/stubs/atomicops_internals_pnacl.h> -#elif (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 7)) || (__GNUC__ > 4)) || \ - (defined(__clang__) && __has_extension(c_atomic)) +#elif (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 7)) || (__GNUC__ > 4)) #include <google/protobuf/stubs/atomicops_internals_generic_gcc.h> +#elif defined(__clang__) +#if __has_extension(c_atomic) +#include <google/protobuf/stubs/atomicops_internals_generic_gcc.h> +#else +GOOGLE_PROTOBUF_ATOMICOPS_ERROR +#endif #else GOOGLE_PROTOBUF_ATOMICOPS_ERROR #endif diff --git a/src/google/protobuf/stubs/platform_macros.h b/src/google/protobuf/stubs/platform_macros.h index 02c79a61..1d1d59a7 100644 --- a/src/google/protobuf/stubs/platform_macros.h +++ b/src/google/protobuf/stubs/platform_macros.h @@ -33,6 +33,9 @@ #include <google/protobuf/stubs/common.h> +#define GOOGLE_PROTOBUF_PLATFORM_ERROR \ +#error "Host platform was not detected as supported by protobuf" + // Processor architecture detection. For more info on what's defined, see: // http://msdn.microsoft.com/en-us/library/b0084kay.aspx // http://www.agner.org/optimize/calling_conventions.pdf @@ -62,17 +65,22 @@ #endif #elif defined(__pnacl__) #define GOOGLE_PROTOBUF_ARCH_32_BIT 1 -#elif defined(__GNUC__) && \ - ((((__GNUC__ == 4) && (__GNUC_MINOR__ >= 7)) || (__GNUC__ > 4)) || \ - (defined(__clang__) && __has_extension(c_atomic))) -// We fallback to the generic GCC >= 4.7 implementation in atomicops.h +#elif defined(__GNUC__) +# if (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 7)) || (__GNUC__ > 4)) +// We fallback to the generic Clang/GCC >= 4.7 implementation in atomicops.h +# elif defined(__clang__) +# if !__has_extension(c_atomic) +GOOGLE_PROTOBUF_PLATFORM_ERROR +# endif +// We fallback to the generic Clang/GCC >= 4.7 implementation in atomicops.h +# endif # if __LP64__ # define GOOGLE_PROTOBUF_ARCH_64_BIT 1 # else # define GOOGLE_PROTOBUF_ARCH_32_BIT 1 # endif #else -#error Host architecture was not detected as supported by protobuf +GOOGLE_PROTOBUF_PLATFORM_ERROR #endif #if defined(__APPLE__) |