Use a macro for when __has_cpp_attribute is unsupported

And the standard macro is __has_cpp_attribute, not __has_attribute.
This commit is contained in:
Chris Robinson 2023-03-10 21:03:08 -08:00
parent 8c3948c4de
commit 5aeeffec80

View File

@ -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 {