xcb.h: use __has_attribute to check for attribute((__packed__)) support

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/lib/libxcb/-/merge_requests/64>
This commit is contained in:
Alan Coopersmith 2024-12-14 15:31:27 -08:00
parent 124690ba63
commit 021e887de9

View File

@ -47,7 +47,11 @@ extern "C" {
* @file xcb.h
*/
#ifdef __GNUC__
#ifndef __has_attribute
# define __has_attribute(x) 0 /* Compatibility with older compilers. */
#endif
#if defined(__GNUC__) || __has_attribute(__packed__)
#define XCB_PACKED __attribute__((__packed__))
#else
#define XCB_PACKED