From d9f6be3a61edfe9e1bce01ea9b11e2bcb16f9618 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 18 Jan 2019 12:48:01 -0500 Subject: [PATCH] Fix -Wundef errors with __GNUC__ Fixes https://github.com/harfbuzz/harfbuzz/issues/1549 --- src/hb-common.h | 4 ++-- src/hb.hh | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/hb-common.h b/src/hb-common.h index ae23698a5..247a02d5d 100644 --- a/src/hb-common.h +++ b/src/hb-common.h @@ -67,7 +67,7 @@ typedef unsigned __int64 uint64_t; # include #endif -#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) +#if defined(__GNUC__) && ((__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) #define HB_DEPRECATED __attribute__((__deprecated__)) #elif defined(_MSC_VER) && (_MSC_VER >= 1300) #define HB_DEPRECATED __declspec(deprecated) @@ -75,7 +75,7 @@ typedef unsigned __int64 uint64_t; #define HB_DEPRECATED #endif -#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) +#if defined(__GNUC__) && ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)) #define HB_DEPRECATED_FOR(f) __attribute__((__deprecated__("Use '" #f "' instead"))) #elif defined(_MSC_FULL_VER) && (_MSC_FULL_VER > 140050320) #define HB_DEPRECATED_FOR(f) __declspec(deprecated("is deprecated. Use '" #f "' instead")) diff --git a/src/hb.hh b/src/hb.hh index c59986e8d..c0ad83925 100644 --- a/src/hb.hh +++ b/src/hb.hh @@ -208,7 +208,7 @@ extern "C" int hb_memalign_impl(void **memptr, size_t alignment, size_t size); HB_UNUSED typedef int HB_PASTE(static_assertion_failed_at_line_, __LINE__) [(e) ? 1 : -1] #endif // static_assert -#ifdef __GNUC__ +#if defined(__GNUC__) #if (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 8)) #define thread_local __thread #endif @@ -258,7 +258,7 @@ struct _hb_alignof #define __attribute__(x) #endif -#if __GNUC__ >= 3 +#if defined(__GNUC__) && (__GNUC__ >= 3) #define HB_PURE_FUNC __attribute__((pure)) #define HB_CONST_FUNC __attribute__((const)) #define HB_PRINTF_FUNC(format_idx, arg_idx) __attribute__((__format__ (__printf__, format_idx, arg_idx))) @@ -267,7 +267,7 @@ struct _hb_alignof #define HB_CONST_FUNC #define HB_PRINTF_FUNC(format_idx, arg_idx) #endif -#if __GNUC__ >= 4 +#if defined(__GNUC__) && (__GNUC__ >= 4) #define HB_UNUSED __attribute__((unused)) #elif defined(_MSC_VER) /* https://github.com/harfbuzz/harfbuzz/issues/635 */ #define HB_UNUSED __pragma(warning(suppress: 4100 4101)) @@ -290,7 +290,7 @@ struct _hb_alignof # endif #endif -#if __GNUC__ >= 3 +#if defined(__GNUC__) && (__GNUC__ >= 3) #define HB_FUNC __PRETTY_FUNCTION__ #elif defined(_MSC_VER) #define HB_FUNC __FUNCSIG__ @@ -322,7 +322,7 @@ struct _hb_alignof #if defined(__clang__) && __cplusplus >= 201103L /* clang's fallthrough annotations are only available starting in C++11. */ # define HB_FALLTHROUGH [[clang::fallthrough]] -#elif __GNUC__ >= 7 +#elif defined(__GNUC__) && (__GNUC__ >= 7) /* GNU fallthrough attribute is available from GCC7 */ # define HB_FALLTHROUGH __attribute__((fallthrough)) #elif defined(_MSC_VER)