Prevent perl header overriding our *snprintf macros, and give it a usable PERL_UNUSED...
authorAndrew Dunstan <[email protected]>
Mon, 25 Apr 2011 16:46:59 +0000 (12:46 -0400)
committerAndrew Dunstan <[email protected]>
Mon, 25 Apr 2011 16:46:59 +0000 (12:46 -0400)
This quiets compiler warnings about redefined macros and unused Perl__unused variables. The
redefinition of snprintf and vsnprintf is something we want to avoid anyway, if we've
gone to the bother of setting up the macros to point to our implementation.

src/pl/plperl/plperl.h

index 5eaec73d2b18fa5398e504c6da165d74d39ec906..a375bb5e31619d27a26e892942174730bad6e2bb 100644 (file)
 #endif
 #endif
 
+/*
+ * Supply a value of PERL_UNUSED_DECL that will satisfy gcc - the one
+ * perl itself supplies doesn't seem to.
+ */
+#if defined(__GNUC__)
+#define PERL_UNUSED_DECL __attribute__ ((unused))
+#endif
+
+/*
+ * Sometimes perl carefully scribbles on our *printf macros.
+ * So we undefine them here and redefine them after it's done its dirty deed.
+ */
+
+#ifdef USE_REPL_SNPRINTF
+#undef snprintf
+#undef vsnprintf
+#endif
+
+
 /* required for perl API */
 #include "EXTERN.h"
 #include "perl.h"
 #include "XSUB.h"
 
+/* put back our snprintf and vsnprintf */
+#ifdef USE_REPL_SNPRINTF
+#ifdef snprintf
+#undef snprintf
+#endif
+#ifdef vsnprintf
+#undef vsnprintf
+#endif
+#ifdef __GNUC__
+#define vsnprintf(...)  pg_vsnprintf(__VA_ARGS__)
+#define snprintf(...)   pg_snprintf(__VA_ARGS__)
+#else
+#define vsnprintf       pg_vsnprintf
+#define snprintf        pg_snprintf
+#endif /* __GNUC__ */
+#endif /*  USE_REPL_SNPRINTF */
+
 /* perl version and platform portability */
 #define NEED_eval_pv
 #define NEED_newRV_noinc