diff --git a/modules/opentelemetry/opentelemetry.cpp b/modules/opentelemetry/opentelemetry.cpp index fc5a0940b2b..5124869485b 100644 --- a/modules/opentelemetry/opentelemetry.cpp +++ b/modules/opentelemetry/opentelemetry.cpp @@ -52,8 +52,16 @@ namespace otelotlp = opentelemetry::exporter::otlp; #ifdef __cplusplus /* Relax C-only headers for C++ compilation. */ #define class class_keyword -#undef HAVE_STDATOMIC #undef HAVE_GENERICS +/* atomic.h defines atomic_t using the C11 keyword `_Atomic(T)` when + * HAVE_STDATOMIC is set. `_Atomic` is C-only and not valid in C++, so + * we shim it to std::atomic for this C++ translation unit. With + * the shim, atomic.h's typedef resolves as + * typedef std::atomic atomic_t; + * on every architecture. HAVE_STDATOMIC itself is set by Makefile.defs + * or compiler auto-detection, so no change to its value is needed here. */ +#include +#define _Atomic(T) std::atomic #endif extern "C" {