From 90f3228dce874d9263495c51cf906f51f2fadcfd Mon Sep 17 00:00:00 2001 From: David Levine Date: Mon, 28 Aug 2017 21:03:21 -0400 Subject: [PATCH] Restrict use of alloc_size function attribute to gcc >= 4.3.0. It's not supported by gcc 4.2.4. CHECK_PRINTF doesn't work perfectly with gcc 4.2.1, so disable that with gcc < 4.3.0 as well. Fix to commit c066b395274021182a5f0530ccfeb1bcd167d860. --- h/mh.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/h/mh.h b/h/mh.h index 2723a42a..6b4466bf 100644 --- a/h/mh.h +++ b/h/mh.h @@ -40,9 +40,14 @@ typedef unsigned char boolean; /* not int so we can pack in a structure */ /* If we're using gcc then tell it extra information so it can do more * compile-time checks. */ #if __GNUC__ > 2 -#define NORETURN __attribute__((__noreturn__)) -#define CHECK_PRINTF(fmt, arg) __attribute__((format(printf, fmt, arg))) +#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) #define ALLOC_SIZE(...) __attribute__((alloc_size(__VA_ARGS__))) +#define CHECK_PRINTF(fmt, arg) __attribute__((format(printf, fmt, arg))) +#else /* gcc < 4.3.0 */ +#define ALLOC_SIZE(...) +#define CHECK_PRINTF(fmt, arg) +#endif /* gcc < 4.3.0 */ +#define NORETURN __attribute__((__noreturn__)) #define CONST __attribute__((const)) #define MALLOC __attribute__((malloc)) #define NONNULL(...) __attribute__((nonnull(__VA_ARGS__))) -- 2.56.0