From e80ac987ba3eb30b53ce006d0b0eb775935e931e Mon Sep 17 00:00:00 2001 From: owent Date: Fri, 13 May 2022 19:17:51 +0800 Subject: [PATCH] Fix compatibility of `OPENTELEMETRY_LIKELY_IF` Signed-off-by: owent --- api/include/opentelemetry/common/macros.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/api/include/opentelemetry/common/macros.h b/api/include/opentelemetry/common/macros.h index 231d5368f0..771e38c139 100644 --- a/api/include/opentelemetry/common/macros.h +++ b/api/include/opentelemetry/common/macros.h @@ -7,20 +7,20 @@ #include "opentelemetry/version.h" -#ifndef OPENTELEMETRY_LIKELY_IF +#if !defined(OPENTELEMETRY_LIKELY_IF) && defined(__cplusplus) # if defined(__has_cpp_attribute) # if __has_cpp_attribute(likely) # define OPENTELEMETRY_LIKELY_IF(...) \ if (__VA_ARGS__) \ [[likely]] # endif -# elif defined(__clang__) +# elif __cplusplus >= 202002L && defined(__clang__) # if __clang_major__ >= 12 # define OPENTELEMETRY_LIKELY_IF(...) \ if (__VA_ARGS__) \ [[likely]] # endif -# elif defined(__GNUC__) +# elif __cplusplus >= 202002L && defined(__GNUC__) # if __GNUC__ >= 9 # define OPENTELEMETRY_LIKELY_IF(...) \ if (__VA_ARGS__) \