From: Willy Tarreau Date: Mon, 9 May 2022 17:45:06 +0000 (+0200) Subject: MINOR: compiler: add a new macro to set an attribute on an enum when possible X-Git-Tag: v2.6-dev10~71 X-Git-Url: http://git.haproxy.org/?a=commitdiff_plain;h=4fc2cd7c8e30fde56ab46d2b945615617b45e0f7;p=haproxy-3.0.git MINOR: compiler: add a new macro to set an attribute on an enum when possible Gcc 6 and above support placing an attribute on an enum's value. This is convenient for marking some values as deprecated. We just need the macro because older versions fail to parse __attribute__() there. --- diff --git a/include/haproxy/compiler.h b/include/haproxy/compiler.h index a23e62a..49356da 100644 --- a/include/haproxy/compiler.h +++ b/include/haproxy/compiler.h @@ -207,6 +207,14 @@ }) #endif + +/* From gcc 6 and above, enum values may have attributes */ +#if __GNUC_PREREQ__(6, 0) +#define ENUM_ATTRIBUTE(x) __attribute__(x) +#else +#define ENUM_ATTRIBUTE(x) +#endif + /* Some architectures have a double-word CAS, sometimes even dual-8 bytes. * Some architectures support unaligned accesses, others are fine with them * but only for non-atomic operations. Also mention those supporting unaligned