Preprocessor error in gcc 5.2
I encountered a compile error while compiling libspf2 1.2.10 with gcc 5.2.1 on Linux. The issue is that it does not like C99-style variadic macros that do not expand to at least one argument. For example:
spf_dns.c: In function 'SPF_dns_debug_post': ../../src/include/spf_log.h:66:86: error: expected expression before ')' token #define SPF_debugf(format, ... ) SPF_debugx( FILE, LINE, format, VA_ARGS )
due to:
SPF_debugf(" - Unknown RR type");
The attached patch fixes the problem for gcc and should be fully portable elsewhere.
Dan
libspf2-1.2.10-mga-varargs.patch
Index: libspf2-1.2.10/src/include/spf_log.h
===================================================================
--- libspf2-1.2.10/src/include/spf_log.h
+++ libspf2-1.2.10/src/include/spf_log.h 2015-10-20 23:23:04.579055906 +0200
@@ -60,10 +60,10 @@
#if defined( __STDC_VERSION__ ) && __STDC_VERSION__ >= 199901L
-#define SPF_errorf(format, ... ) SPF_errorx( __FILE__, __LINE__, format, __VA_ARGS__ )
-#define SPF_warningf(format, ... ) SPF_warningx( __FILE__, __LINE__, format, __VA_ARGS__ )
-#define SPF_infof(format, ... ) SPF_infox( __FILE__, __LINE__, format, __VA_ARGS__ )
-#define SPF_debugf(format, ... ) SPF_debugx( __FILE__, __LINE__, format, __VA_ARGS__ )
+#define SPF_errorf(...) SPF_errorx( __FILE__, __LINE__, __VA_ARGS__ )
+#define SPF_warningf(...) SPF_warningx( __FILE__, __LINE__, __VA_ARGS__ )
+#define SPF_infof(...) SPF_infox( __FILE__, __LINE__, __VA_ARGS__ )
+#define SPF_debugf(...) SPF_debugx( __FILE__, __LINE__, __VA_ARGS__ )
#elif defined( __GNUC__ )
Building with gcc-5 was fixed by 5852828582f556e73751076ad092f72acf7fc8b6, but it seems gcc-specific.
I can confirm this bug for gentoo gcc-5.4.0 with libspf2-1.2.0.
Error message is identic to sheveks report and his patch works. So this bug is not fixed as of August 12, 2017...