diff options
author | Explorer09 <explorer09@gmail.com> | 2023-10-11 03:37:39 +0800 |
---|---|---|
committer | Explorer09 <explorer09@gmail.com> | 2023-10-11 04:22:54 +0800 |
commit | f541f70d0ecbb9fd80bea9909c1783b92d46d695 (patch) | |
tree | 346c0af3ae7e3d73a6a3f0b27c5ccc2482a4b25d /Macros.h | |
parent | 83041f3550ee5bb83b6f9c4dcae90d59b33e0fb5 (diff) |
Add configure check for nonnull attribute
The main reason I do this is to document the minimum compiler version
(GCC 3.3) for the attribute. But it may work with other compilers, too.
Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
Diffstat (limited to 'Macros.h')
-rw-r--r-- | Macros.h | 14 |
1 files changed, 12 insertions, 2 deletions
@@ -42,7 +42,6 @@ in the source distribution for its full text. #ifdef __GNUC__ // defined by GCC and Clang #define ATTR_FORMAT(type, index, check) __attribute__((format (type, index, check))) -#define ATTR_NONNULL __attribute__((nonnull)) #define ATTR_NORETURN __attribute__((noreturn)) #define ATTR_UNUSED __attribute__((unused)) #define ATTR_MALLOC __attribute__((malloc)) @@ -50,13 +49,24 @@ in the source distribution for its full text. #else /* __GNUC__ */ #define ATTR_FORMAT(type, index, check) -#define ATTR_NONNULL #define ATTR_NORETURN #define ATTR_UNUSED #define ATTR_MALLOC #endif /* __GNUC__ */ +#ifdef HAVE_ATTR_NONNULL + +#define ATTR_NONNULL __attribute__((nonnull)) +#define ATTR_NONNULL_N(...) __attribute__((nonnull(__VA_ARGS__))) + +#else + +#define ATTR_NONNULL +#define ATTR_NONNULL_N(...) + +#endif /* HAVE_ATTR_NONNULL */ + #ifdef HAVE_ATTR_ALLOC_SIZE #define ATTR_ALLOC_SIZE1(a) __attribute__((alloc_size (a))) |