From 89350fda665ceeba49bb7dbabe3ce68e4aa5040d Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Thu, 25 Nov 2021 16:02:29 -0500 Subject: [PATCH] Fix: static_assert unavailable with glibc < 2.16 gcc 4.8 introduces support for C11, and gcc 4.6 introduces support for _Static_assert. Therefore, using _Static_assert when C11 is detected is always OK. However, using static_assert in C11 depends on glibc >= 2.16. Even though the minimum version requirement for glibc is not documented in the README.md file, make a best effort to keep compatibility with older glibc. Fixes: #1331 Signed-off-by: Mathieu Desnoyers Change-Id: I33b65b839ea5ecd0f710179a7ef6fb6f5fda2e17 --- include/lttng/ust-compiler.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/lttng/ust-compiler.h b/include/lttng/ust-compiler.h index 32fd1bb2..674b519c 100644 --- a/include/lttng/ust-compiler.h +++ b/include/lttng/ust-compiler.h @@ -65,9 +65,12 @@ * static assertion. This parameter must be a valid C identifier as it will * be used as a typedef name. */ -#if defined (__cplusplus) || __STDC_VERSION__ >= 201112L +#ifdef __cplusplus #define lttng_ust_static_assert(predicate, msg, c_identifier_msg) \ static_assert(predicate, msg) +#elif __STDC_VERSION__ >= 201112L +#define lttng_ust_static_assert(predicate, msg, c_identifier_msg) \ + _Static_assert(predicate, msg) #else /* * Evaluates the predicate and emit a compilation error on failure. -- 2.34.1