[clang][compiler.h] Expose a few more macros for Clang

Clang sets the defines for GCC 4.2.1, so we have to check __clang__ for
these macros in addition to the GCC version.
This commit is contained in:
Alex Richardson
2021-12-09 14:35:37 +00:00
committed by Travis Geiselbrecht
parent e40ac2a883
commit 365bb4e7a7

View File

@@ -87,19 +87,22 @@
#define __WARN_UNUSED_RESULT
#endif
#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)
#if defined(__clang__)
/* Clang does not support externally_visible, used should be similar. */
#define __EXTERNALLY_VISIBLE __attribute__((used))
#elif (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)
#define __EXTERNALLY_VISIBLE __attribute__((externally_visible))
#else
#define __EXTERNALLY_VISIBLE
#endif
#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) || defined(__clang__)
#define __UNREACHABLE __builtin_unreachable()
#else
#define __UNREACHABLE
#endif
#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) || defined(__clang__)
#ifdef __cplusplus
#define STATIC_ASSERT(e) static_assert(e, #e)
#else