aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndres Freund <andres@anarazel.de>2023-01-25 09:59:26 -0800
committerAndres Freund <andres@anarazel.de>2023-01-25 09:59:26 -0800
commit23c12329a755ad9c70135463d3f067241daf1dcc (patch)
tree437db4374e9376720c1165e4fd4f07b61cfce304
parent3b4ac33254e1291f0b3c94f1cb770137c418ce2e (diff)
downloadpostgresql-23c12329a755ad9c70135463d3f067241daf1dcc.tar.gz
postgresql-23c12329a755ad9c70135463d3f067241daf1dcc.zip
plpython: Avoid the need to redefine *printf macros
Until now we undefined and then redefined a lot of *printf macros due to worries about conflicts with Python.h macro definitions. Current Python.h doesn't define any *printf macros, and older versions just defined snprintf, vsnprintf, guarded by #if defined(MS_WIN32) && !defined(HAVE_SNPRINTF). Thus we can replace the undefine/define section with a single #define HAVE_SNPRINTF 1 Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/20230124165814.2njc7gnvubn2amh6@awork3.anarazel.de
-rw-r--r--src/pl/plpython/plpython.h48
1 files changed, 3 insertions, 45 deletions
diff --git a/src/pl/plpython/plpython.h b/src/pl/plpython/plpython.h
index 2af0d04d1f8..2d18fc2dc1b 100644
--- a/src/pl/plpython/plpython.h
+++ b/src/pl/plpython/plpython.h
@@ -30,17 +30,10 @@
#undef _XOPEN_SOURCE
/*
- * Sometimes python carefully scribbles on our *printf macros.
- * So we undefine them here and redefine them after it's done its dirty deed.
+ * Python versions <= 3.8 otherwise define a replacement, causing macro
+ * redefinition warnings.
*/
-#undef vsnprintf
-#undef snprintf
-#undef vsprintf
-#undef sprintf
-#undef vfprintf
-#undef fprintf
-#undef vprintf
-#undef printf
+#define HAVE_SNPRINTF 1
#if defined(_MSC_VER) && defined(_DEBUG)
/* Python uses #pragma to bring in a non-default libpython on VC++ if
@@ -63,41 +56,6 @@
#undef TEXTDOMAIN
#define TEXTDOMAIN PG_TEXTDOMAIN("plpython")
-/* put back our *printf macros ... this must match src/include/port.h */
-#ifdef vsnprintf
-#undef vsnprintf
-#endif
-#ifdef snprintf
-#undef snprintf
-#endif
-#ifdef vsprintf
-#undef vsprintf
-#endif
-#ifdef sprintf
-#undef sprintf
-#endif
-#ifdef vfprintf
-#undef vfprintf
-#endif
-#ifdef fprintf
-#undef fprintf
-#endif
-#ifdef vprintf
-#undef vprintf
-#endif
-#ifdef printf
-#undef printf
-#endif
-
-#define vsnprintf pg_vsnprintf
-#define snprintf pg_snprintf
-#define vsprintf pg_vsprintf
-#define sprintf pg_sprintf
-#define vfprintf pg_vfprintf
-#define fprintf pg_fprintf
-#define vprintf pg_vprintf
-#define printf(...) pg_printf(__VA_ARGS__)
-
/*
* Used throughout, so it's easier to just include it everywhere.
*/