]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: Add a common HAVE_TYPE_CHECKS
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Fri, 7 Apr 2017 06:11:53 +0000 (09:11 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Fri, 7 Apr 2017 11:26:35 +0000 (14:26 +0300)
I'm not sure if it should be checking gcc >= 3.0 or 3.3, but they're
all old so doesn't really matter.

The __cplusplus check was added to both, since it wouldn't have done
anything anyway as COMPILE_ERROR_IF_TRUE() is 0 for __cplusplus.

src/lib/compat.h
src/lib/macros.h

index 937b09722be4e45a73486e36bab2450cbe800a9a..3984303fa3967d421432373e561d5f7bb93592ef 100644 (file)
 #  define LLONG_MAX 9223372036854775807LL
 #endif
 
+#if ((__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 3)) && \
+       defined(HAVE_TYPEOF)) && !defined(__cplusplus)
+#  define HAVE_TYPE_CHECKS
+#endif
+
 /* We really want NULL to be a pointer, since we have various type-checks
    that may result in compiler warnings/errors if it's not. */
 #ifndef __cplusplus
index 54500cfd6db7733966bb7ba27669d7ae8d15e068..bbca58601757990f96f376958bc3a7689c4eea8d 100644 (file)
 #endif
 
 /* Macros to provide type safety for callback functions' context parameters */
-#if ((__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 3)) && defined(HAVE_TYPEOF))
+#ifdef HAVE_TYPE_CHECKS
 #  define CALLBACK_TYPECHECK(callback, type) \
        (COMPILE_ERROR_IF_TRUE(!__builtin_types_compatible_p( \
                typeof(&callback), type)) ? 1 : 0)
 #  define COMPILE_ERROR_IF_TRUE(condition) 0
 #endif
 
-#if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 0)) && !defined(__cplusplus) && defined(HAVE_TYPEOF)
+#ifdef HAVE_TYPE_CHECKS
 #  define COMPILE_ERROR_IF_TYPES_NOT_COMPATIBLE(_a, _b) \
        COMPILE_ERROR_IF_TRUE( \
                !__builtin_types_compatible_p(typeof(_a), typeof(_b)))