From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cagney To: Eli Zaretskii Cc: GDB Patches Subject: Re: [fyi] fix mips-tdep.c -Wprintf(a?"%d":"%d%d", ...) Date: Wed, 21 Feb 2001 10:30:00 -0000 Message-id: <3A9408B5.256F077F@cygnus.com> References: X-SW-Source: 2001-02/msg00426.html Eli Zaretskii wrote: > > On Tue, 20 Feb 2001, Andrew Cagney wrote: > > > I've checked in the attatched. A GCC variant didn't like conditional > > formats vis: > > > > printf (cond ? "arg1=%d" : "arg1=%d arg2+%d", arg1, arg2); > > That's one of my gripes with latest versions of GCC (which version did > you use, btw?): this change caused lots of valid C code to start > emitting tons of warnings. Ulrich Drepper tried to change GCC > maintainers' minds on this one (evidently, glibc uses such expressions > in printf's), to no avail IIRC. > > Isn't there a compiler switch to turn this warning off? Perhaps we > should use it instead of ``fixing'' that which isn't broken. ac131313@localhost$ gcc --version egcs-1.1.2 but I know it is lieing - there should be a ``+ NetBSD patches'' appended. The warning comes from the ``-Wprintf'' flag so I think fixing this little nuance is far less of a hassle than dropping -Wprintf. (To be honest, I personally don't like the ``?:'' operator - I can't debug it - so I don't object to this ``fix'' :-). The other thing to keep in mind is that the ui_out interface strongly discourages the above convention. What was: > printf (cond ? "arg1=%d" : "arg1=%d arg2+%d", arg1, arg2); and I rewrote to something like: printf ("arg1="); printf ("%d", arg1); if (cond) { printf (" arg2+"); printf ("%d", arg2); } will eventually be written as something like: ui_out_text ("arg1="); ui_out_int (arg1, fmt, "arg1"); if (cond) { ui_out_text (" arg2+"); ui_out_int (arg2, fmt, "arg2"); } so I'm in a way just helping the code along a little :-) enjoy, Andrew