aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2023-03-10 21:03:08 -0800
committerChris Robinson <[email protected]>2023-03-10 21:16:00 -0800
commit5aeeffec8063e51f647403b2bbff68bf900b0f9c (patch)
tree1b7d6498ac477302e8605bfb5fd60940435f1559
parent8c3948c4de4b84805664775bbfe64516e1100ad9 (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.h14
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 {