mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-23 06:41:32 +02:00
BUILD: compiler: add a default definition for __has_attribute()
It happens that gcc since 5.x has this macro which is only mentioned once in the doc, associated with __builtin_has_attribute(). Clang had it at least since 3.0. In addition it validates #ifdef when present, so it's easy to detect it. Here we're providing a fallback to another macro __has_attribute_<name> so that it's possible to define that macro to the value 1 for older compilers when the attribute is supported.
This commit is contained in:
parent
08e09f0b3c
commit
2b080f713f
@ -49,6 +49,17 @@
|
||||
#define ___equals_1(x, ...) ____equals_1(x, 0)
|
||||
#define __equals_1(x) ___equals_1(comma_for_one ## x 1)
|
||||
|
||||
/* 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.
|
||||
* In both cases it's possible to test for __has_attribute() using ifdef. When
|
||||
* not defined we remap this to the __has_attribute_<name> macro so that we'll
|
||||
* later be able to implement on a per-compiler basis those which are missing,
|
||||
* by defining __has_attribute_<name> to 1.
|
||||
*/
|
||||
#ifndef __has_attribute
|
||||
#define __has_attribute(x) __equals_1(__has_attribute_ ## x)
|
||||
#endif
|
||||
|
||||
#if !defined(__GNUC__)
|
||||
/* Some versions of glibc irresponsibly redefine __attribute__() to empty for
|
||||
* non-gcc compilers, and as such, silently break all constructors with other
|
||||
|
Loading…
x
Reference in New Issue
Block a user