From 988e19c60715f8f19a9ecee8fbf647bf9d846c95 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Fri, 7 Apr 2023 14:34:38 +0200 Subject: [PATCH] BUILD: compiler: fix __equals_1() on older compilers It appeared that __has_attribute() doesn't work on gcc 4.4 and older because the concatenation of __has_attribute##x isn't resolved as a one before being passed to __equals_1() which immediately concatenates it to comma_for_one. We first need to pass it through an extra layer to resolve this name to a value. The new version was tested with gcc 4.2 to 11.3. This may be backported though it's pretty minor. --- include/haproxy/compiler.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/include/haproxy/compiler.h b/include/haproxy/compiler.h index 5b9c668bb..3e0049376 100644 --- a/include/haproxy/compiler.h +++ b/include/haproxy/compiler.h @@ -50,9 +50,10 @@ * second one. */ #define comma_for_one1 , -#define ____equals_1(x, y, ...) (y) -#define ___equals_1(x, ...) ____equals_1(x, 0) -#define __equals_1(x) ___equals_1(comma_for_one ## x 1) +#define _____equals_1(x, y, ...) (y) +#define ____equals_1(x, ...) _____equals_1(x, 0) +#define ___equals_1(x) ____equals_1(comma_for_one ## x 1) +#define __equals_1(x) ___equals_1(x) /* gcc 5 and clang 3 brought __has_attribute(), which is not well documented in * the case of gcc, but is convenient since handled at the preprocessor level.