diff --git a/benchmark/utils/CxxTests/CxxStdlibPerformance.h b/benchmark/utils/CxxTests/CxxStdlibPerformance.h index e5eed5c7747..311659cb6f6 100644 --- a/benchmark/utils/CxxTests/CxxStdlibPerformance.h +++ b/benchmark/utils/CxxTests/CxxStdlibPerformance.h @@ -5,25 +5,28 @@ #include // FIXME swift-ci linux tests do not support std::span -#ifndef __linux__ +#if defined(__has_include) && __has_include() #include -#endif // __linux__ +#define SPAN_DEFINED 1 +#else +#define SPAN_DEFINED 0 +#endif static const size_t spanSize = 50000; using VectorOfU32 = std::vector; using SetOfU32 = std::set; -#ifndef __linux__ +#if SPAN_DEFINED using ArrayOfU32 = uint32_t[spanSize]; using SpanOfU32 = std::span; -#endif // __linux__ +#endif static inline VectorOfU32 vec; static inline SetOfU32 set; -#ifndef __linux__ +#if SPAN_DEFINED static inline ArrayOfU32 array; static inline SpanOfU32 span; -#endif // __linux__ +#endif inline void initVector(size_t size) { if (!vec.empty()) { @@ -44,7 +47,7 @@ inline void initSet(size_t size) { } } -#ifndef __linux__ +#if SPAN_DEFINED inline void initSpan() { if (!span.empty()) { return; @@ -54,7 +57,7 @@ inline void initSpan() { } span = SpanOfU32(array); } -#endif // __linux__ +#endif inline VectorOfU32 makeVector32(size_t size) { initVector(size);