Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit23c1232

Browse files
committed
plpython: Avoid the need to redefine *printf macros
Until now we undefined and then redefined a lot of *printf macros due toworries about conflicts with Python.h macro definitions. Current Python.hdoesn'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 1Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>Discussion:https://postgr.es/m/20230124165814.2njc7gnvubn2amh6@awork3.anarazel.de
1 parent3b4ac33 commit23c1232

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+
#defineHAVE_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
#defineTEXTDOMAIN PG_TEXTDOMAIN("plpython")
6558

66-
/* put back our *printf macros ... this must match src/include/port.h */
67-
#ifdefvsnprintf
68-
#undef vsnprintf
69-
#endif
70-
#ifdefsnprintf
71-
#undef snprintf
72-
#endif
73-
#ifdefvsprintf
74-
#undef vsprintf
75-
#endif
76-
#ifdefsprintf
77-
#undef sprintf
78-
#endif
79-
#ifdefvfprintf
80-
#undef vfprintf
81-
#endif
82-
#ifdeffprintf
83-
#undef fprintf
84-
#endif
85-
#ifdefvprintf
86-
#undef vprintf
87-
#endif
88-
#ifdefprintf
89-
#undef printf
90-
#endif
91-
92-
#definevsnprintfpg_vsnprintf
93-
#definesnprintfpg_snprintf
94-
#definevsprintfpg_vsprintf
95-
#definesprintfpg_sprintf
96-
#definevfprintfpg_vfprintf
97-
#definefprintfpg_fprintf
98-
#definevprintfpg_vprintf
99-
#defineprintf(...)pg_printf(__VA_ARGS__)
100-
10159
/*
10260
* Used throughout, so it's easier to just include it everywhere.
10361
*/

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp