Macro expansion with "..."
Giuliano Procida
GProcida@Madge.com
Wed Mar 31 23:54:00 GMT 1999
On 03 March 1999, Alexandre Oliva <oliva@dcc.unicamp.br> wrote:
> On Mar 2, 1999, Giuliano Procida <GProcida@Madge.com> wrote:
> > I am trying to get a debug macro to work properly. In cases 2 & 3, when
> > the arg list is empty, the expansion eats one of the other "arguments".
> Did you really post what you were trying to compiling, or did you
> align `, ## args' from PRINTD1 and PRINTD2 with PRINTD3 just before
> posting?
Erm yes, except that the comma got moved in the mail version, oops.
> > #define PRINTD1(fmt,args...) (printf(fmt , ## args))
> > #define PRINTD2(fmt,args...) (printf(fmt "\n" , ## args))
> > #define PRINTD3(fmt,args...) (printf(fmt "\n" "", ## args))
> According to Zack Weinberg, in such constructions, ## deletes the
> preceding sequence of non-whitespace if there are no trailing
> arguments, so you get `,' deleted in the first two cases, and `"",'
> deleted in the last one, which is why all cases work in egcs 1.1.1.
Wouldn't it be more sensible to just delete a comma? Adding space after
the comma fixes all the (7!) variations I tried.
> Thanks for your report
Thank you.
Giuliano Procida.
More information about the Gcc-bugs
mailing list