diff options
author | Martin Storsjo <martin@martin.st> | 2019-01-21 16:09:05 +0200 |
---|---|---|
committer | Martin Storsjo <martin@martin.st> | 2019-01-21 16:14:06 +0200 |
commit | f285813ec15e7c6f8e4839c9eb4f6b0cd2da1990 (patch) | |
tree | c86996f6e511721146481919dcbfb16eeeac72f4 | |
parent | 02103fd6308a40c58013d8ec8610ad8a71075aca (diff) | |
download | fdk-aac-f285813ec15e7c6f8e4839c9eb4f6b0cd2da1990.tar.gz fdk-aac-f285813ec15e7c6f8e4839c9eb4f6b0cd2da1990.tar.bz2 fdk-aac-f285813ec15e7c6f8e4839c9eb4f6b0cd2da1990.zip |
Fix FDK_FALLTHROUGH for apple clang
In the apple branded version of clang, the [[clang::fallthrough]]
attribute isn't supported.
Directly exposing __has_cpp_attribute(clang::fallthrough) to the
preprocessor breaks when building in C mode with GCC, which forces
wrapping it in an extra layer of #ifdef __cplusplus.
-rw-r--r-- | libSYS/include/machine_type.h | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/libSYS/include/machine_type.h b/libSYS/include/machine_type.h index b66d5ad..bd97669 100644 --- a/libSYS/include/machine_type.h +++ b/libSYS/include/machine_type.h @@ -382,13 +382,22 @@ it. Hence, a fully platform-independant way to use alignment is not supported. /************************************************** * Macros regarding static code analysis **************************************************/ -#if defined(__clang__) +#ifdef __cplusplus +#if !defined(__has_cpp_attribute) +#define __has_cpp_attribute(x) 0 +#endif +#if defined(__clang__) && __has_cpp_attribute(clang::fallthrough) #define FDK_FALLTHROUGH [[clang::fallthrough]] -#elif defined(__GNUC__) && (__GNUC__ >= 7) +#endif +#endif + +#ifndef FDK_FALLTHROUGH +#if defined(__GNUC__) && (__GNUC__ >= 7) #define FDK_FALLTHROUGH __attribute__((fallthrough)) #else #define FDK_FALLTHROUGH #endif +#endif #ifdef _MSC_VER /* |