]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: Avoid typeof() if HAVE_TYPEOF isn't set, even if gcc version is high enough.
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 3 Feb 2016 15:56:49 +0000 (17:56 +0200)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 3 Feb 2016 15:56:49 +0000 (17:56 +0200)
This is mainly to test that we can compile without typeof().

src/lib/macros.h

index 7fbca6768a012cfef4d72b58841992af067ad397..f8e4689c193f5ce60edf4c929256ebbc986de762 100644 (file)
 #endif
 
 /* Macros to provide type safety for callback functions' context parameters */
-#if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 3))
+#if ((__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 3)) && defined(HAVE_TYPEOF))
 #  define CALLBACK_TYPECHECK(callback, type) \
        (COMPILE_ERROR_IF_TRUE(!__builtin_types_compatible_p( \
                typeof(&callback), type)) ? 1 : 0)
 #if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 0)) && !defined(__cplusplus)
 #  define COMPILE_ERROR_IF_TRUE(condition) \
        (sizeof(char[1 - 2 * !!(condition)]) - 1)
+#else
+#  define COMPILE_ERROR_IF_TRUE(condition) 0
+#endif
+
+#if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 0)) && !defined(__cplusplus) && defined(HAVE_TYPEOF)
 #  define COMPILE_ERROR_IF_TYPES_NOT_COMPATIBLE(_a, _b) \
        COMPILE_ERROR_IF_TRUE( \
                !__builtin_types_compatible_p(typeof(_a), typeof(_b)))
                !__builtin_types_compatible_p(typeof(_a1), typeof(_b)) && \
                !__builtin_types_compatible_p(typeof(_a2), typeof(_b)))
 #else
-#  define COMPILE_ERROR_IF_TRUE(condition) 0
 #  define COMPILE_ERROR_IF_TYPES_NOT_COMPATIBLE(_a, _b) 0
 #  define COMPILE_ERROR_IF_TYPES2_NOT_COMPATIBLE(_a1, _a2, _b) 0
 #endif