mirror of
https://gitlab.freedesktop.org/libbsd/libbsd.git
synced 2025-01-23 10:36:42 +01:00
include: Use __has_builtin to detect __builtin_offsetof support
The __has_builtin operator is more specific and is supported by GCC and Clang, while __is_identifier() is less specific and only supported by Clang, so we should prefer the former whenever it is available, and only fallback to use the latter when the former is missing and the latter.
This commit is contained in:
parent
ec88b7bbbc
commit
fe21244b05
@ -37,6 +37,9 @@
|
||||
#ifndef __is_identifier
|
||||
#define __is_identifier(x) 1
|
||||
#endif
|
||||
#ifndef __has_builtin
|
||||
#define __has_builtin(x) !__is_identifier(x)
|
||||
#endif
|
||||
|
||||
#ifdef LIBBSD_OVERLAY
|
||||
/*
|
||||
@ -182,7 +185,7 @@
|
||||
* require it.
|
||||
*/
|
||||
#ifndef __offsetof
|
||||
# if LIBBSD_GCC_VERSION >= 0x0401 || !__is_identifier(__builtin_offsetof)
|
||||
# if LIBBSD_GCC_VERSION >= 0x0401 || __has_builtin(__builtin_offsetof)
|
||||
# define __offsetof(type, field) __builtin_offsetof(type, field)
|
||||
# else
|
||||
# ifndef __cplusplus
|
||||
|
Loading…
x
Reference in New Issue
Block a user