Skip to content

Commit 23c1232

Browse files
committed
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
1 parent 3b4ac33 commit 23c1232

File tree

1 file changed

+3
-45
lines changed

1 file changed

+3
-45
lines changed

src/pl/plpython/plpython.h

Lines changed: 3 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,10 @@
3030
#undef _XOPEN_SOURCE
3131

3232
/*
33-
* Sometimes python carefully scribbles on our *printf macros.
34-
* So we undefine them here and redefine them after it's done its dirty deed.
33+
* Python versions <= 3.8 otherwise define a replacement, causing macro
34+
* redefinition warnings.
3535
*/
36-
#undef vsnprintf
37-
#undef snprintf
38-
#undef vsprintf
39-
#undef sprintf
40-
#undef vfprintf
41-
#undef fprintf
42-
#undef vprintf
43-
#undef printf
36+
#define HAVE_SNPRINTF 1
4437

4538
#if defined(_MSC_VER) && defined(_DEBUG)
4639
/* Python uses #pragma to bring in a non-default libpython on VC++ if
@@ -63,41 +56,6 @@
6356
#undef TEXTDOMAIN
6457
#define TEXTDOMAIN PG_TEXTDOMAIN("plpython")
6558

66-
/* put back our *printf macros ... this must match src/include/port.h */
67-
#ifdef vsnprintf
68-
#undef vsnprintf
69-
#endif
70-
#ifdef snprintf
71-
#undef snprintf
72-
#endif
73-
#ifdef vsprintf
74-
#undef vsprintf
75-
#endif
76-
#ifdef sprintf
77-
#undef sprintf
78-
#endif
79-
#ifdef vfprintf
80-
#undef vfprintf
81-
#endif
82-
#ifdef fprintf
83-
#undef fprintf
84-
#endif
85-
#ifdef vprintf
86-
#undef vprintf
87-
#endif
88-
#ifdef printf
89-
#undef printf
90-
#endif
91-
92-
#define vsnprintf pg_vsnprintf
93-
#define snprintf pg_snprintf
94-
#define vsprintf pg_vsprintf
95-
#define sprintf pg_sprintf
96-
#define vfprintf pg_vfprintf
97-
#define fprintf pg_fprintf
98-
#define vprintf pg_vprintf
99-
#define printf(...) pg_printf(__VA_ARGS__)
100-
10159
/*
10260
* Used throughout, so it's easier to just include it everywhere.
10361
*/

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy