diff options
author | Chris Robinson <[email protected]> | 2023-03-10 21:03:08 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2023-03-10 21:16:00 -0800 |
commit | 5aeeffec8063e51f647403b2bbff68bf900b0f9c (patch) | |
tree | 1b7d6498ac477302e8605bfb5fd60940435f1559 | |
parent | 8c3948c4de4b84805664775bbfe64516e1100ad9 (diff) |
Use a macro for when __has_cpp_attribute is unsupported
And the standard macro is __has_cpp_attribute, not __has_attribute.
-rw-r--r-- | common/opthelpers.h | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/common/opthelpers.h b/common/opthelpers.h index f1d9b74a..596c2455 100644 --- a/common/opthelpers.h +++ b/common/opthelpers.h @@ -11,6 +11,12 @@ #define HAS_BUILTIN(x) (0) #endif +#ifdef __has_cpp_attribute +#define HAS_ATTRIBUTE __has_cpp_attribute +#else +#define HAS_ATTRIBUTE(x) (0) +#endif + #ifdef __GNUC__ #define force_inline [[gnu::always_inline]] inline #elif defined(_MSC_VER) @@ -39,12 +45,12 @@ /* This shouldn't be needed since unknown attributes are ignored, but older * versions of GCC choke on the attribute syntax in certain situations. */ -#if !__has_attribute(likely) -#define LIKELY -#define UNLIKELY -#else +#if HAS_ATTRIBUTE(likely) #define LIKELY [[likely]] #define UNLIKELY [[unlikely]] +#else +#define LIKELY +#define UNLIKELY #endif namespace al { |