]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUILD: compiler: fix __equals_1() on older compilers
authorWilly Tarreau <w@1wt.eu>
Fri, 7 Apr 2023 12:34:38 +0000 (14:34 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 7 Apr 2023 16:14:28 +0000 (18:14 +0200)
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

index 5b9c668bb44ec8a33a4faef1c01cfcbac9493190..3e00493768331f00385f8148fc623b337dd7d84c 100644 (file)
  * 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.