From: Willy Tarreau Date: Fri, 7 Apr 2023 12:34:38 +0000 (+0200) Subject: BUILD: compiler: fix __equals_1() on older compilers X-Git-Tag: v2.8-dev7~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=988e19c60715f8f19a9ecee8fbf647bf9d846c95;p=thirdparty%2Fhaproxy.git 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. --- diff --git a/include/haproxy/compiler.h b/include/haproxy/compiler.h index 5b9c668bb4..3e00493768 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.