Re: [HACKERS] snprintf causes regression
Bruce Momjian <[email protected]> Fri, 11 Mar 2005 12:14:26 -0500 (EST)
| Newsgroups | gmane.comp.db.postgresql.devel.win32,gmane.comp.db.postgresql.devel.general |
|---|---|
| Message-ID | <[email protected]> |
[email protected] wrote: > > Tom Lane wrote: > >> [email protected] writes: > >> >>> Please see my posting about using a macro for snprintf. > >> > >> > Wasn't the issue about odd behavior of the Win32 linker choosing the > >> wrong > >> > vnsprintf? > >> > >> You're right, the point about the macro was to avoid linker weirdness on > >> Windows. We need to do that part in any case. I think Bruce confused > >> that issue with the one about whether our version supported %n$ > >> adequately ... which it doesn't just yet ... > > > > Perhaps I am reading old email in this reply but I thought I should > > clarify: > > > > Once we do: > > > > #define vsnprintf(...) pg_vsnprintf(__VA_ARGS__) > > #define snprintf(...) pg_snprintf(__VA_ARGS__) > > #define printf(...) pg_printf(__VA_ARGS__) > > > I'm not sure that macros can have variable number of arguments on all > supported platforms. I've been burnt by this before. The actual patch is: + #ifdef __GNUC__ + #define vsnprintf(...) pg_vsnprintf(__VA_ARGS__) + #define snprintf(...) pg_snprintf(__VA_ARGS__) + #define printf(...) pg_printf(__VA_ARGS__) + #else + #define vsnprintf pg_vsnprintf + #define snprintf pg_snprintf + #define printf pg_printf + #endif -- Bruce Momjian | http://candle.pha.pa.us [email protected] | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073 ---------------------------(end of broadcast)--------------------------- TIP 2: you can get off all lists at once with the unregister command (send "unregister YourEmailAddressHere" to [email protected])