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

Commit8b91d25

Browse files
committed
Clean up *printf macros to avoid conflict with format archetypes.
We must define the macro "printf" with arguments, else it can messup format archetype attributes in builds where PG_PRINTF_ATTRIBUTEis just "printf". Fortunately, that's easy to do now that we'rerequiring C99; we can use __VA_ARGS__.On the other hand, it's better not to use __VA_ARGS__ for the restof the *printf crew, so that one can take the addresses of thosefunctions without surprises.I'd proposed doing this some time ago, but forgot to make it happen;buildfarm failures subsequent to96bf88d reminded me.Discussion:https://postgr.es/m/22709.1535135640@sss.pgh.pa.usDiscussion:https://postgr.es/m/20180926190934.ea4xvzhkayuw7gkx@alap3.anarazel.de
1 parenta6b88d6 commit8b91d25

File tree

3 files changed

+7
-23
lines changed

3 files changed

+7
-23
lines changed

‎src/include/port.h

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -173,25 +173,19 @@ extern intpg_fprintf(FILE *stream, const char *fmt,...) pg_attribute_printf(2,
173173
externintpg_printf(constchar*fmt,...)pg_attribute_printf(1,2);
174174

175175
/*
176-
*The GCC-specific code below prevents the pg_attribute_printf above from
177-
*being replaced, and this is required because gcc doesn't know anything
178-
*about pg_printf.
176+
* We use __VA_ARGS__ for printf to prevent replacing references to
177+
* the "printf" format archetype in format() attribute declarations.
178+
* That unfortunately means that taking a function pointer to printf
179+
* will not do what we'd wish. (If you need to do that, you must name
180+
* pg_printf explicitly.) For printf's sibling functions, use
181+
* parameterless macros so that function pointers will work unsurprisingly.
179182
*/
180-
#ifdef__GNUC__
181-
#definevsnprintf(...)pg_vsnprintf(__VA_ARGS__)
182-
#definesnprintf(...)pg_snprintf(__VA_ARGS__)
183-
#definesprintf(...)pg_sprintf(__VA_ARGS__)
184-
#definevfprintf(...)pg_vfprintf(__VA_ARGS__)
185-
#definefprintf(...)pg_fprintf(__VA_ARGS__)
186-
#defineprintf(...)pg_printf(__VA_ARGS__)
187-
#else
188183
#definevsnprintfpg_vsnprintf
189184
#definesnprintfpg_snprintf
190185
#definesprintfpg_sprintf
191186
#definevfprintfpg_vfprintf
192187
#definefprintfpg_fprintf
193-
#defineprintfpg_printf
194-
#endif
188+
#defineprintf(...)pg_printf(__VA_ARGS__)
195189

196190
/* Replace strerror() with our own, somewhat more robust wrapper */
197191
externchar*pg_strerror(interrnum);

‎src/pl/plperl/plperl.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,8 @@
102102
#ifdefvsnprintf
103103
#undef vsnprintf
104104
#endif
105-
#ifdef__GNUC__
106-
#definevsnprintf(...)pg_vsnprintf(__VA_ARGS__)
107-
#definesnprintf(...)pg_snprintf(__VA_ARGS__)
108-
#else
109105
#definevsnprintfpg_vsnprintf
110106
#definesnprintfpg_snprintf
111-
#endif/* __GNUC__ */
112107

113108
/* perl version and platform portability */
114109
#defineNEED_eval_pv

‎src/pl/plpython/plpython.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,13 +127,8 @@ typedef int Py_ssize_t;
127127
#ifdefvsnprintf
128128
#undef vsnprintf
129129
#endif
130-
#ifdef__GNUC__
131-
#definevsnprintf(...)pg_vsnprintf(__VA_ARGS__)
132-
#definesnprintf(...)pg_snprintf(__VA_ARGS__)
133-
#else
134130
#definevsnprintfpg_vsnprintf
135131
#definesnprintfpg_snprintf
136-
#endif/* __GNUC__ */
137132

138133
/*
139134
* Used throughout, and also by the Python 2/3 porting layer, so it's easier to

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp