Macro expansion with "..."
Alexandre Oliva
oliva@dcc.unicamp.br
Wed Mar 31 23:54:00 GMT 1999
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?
> #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.
Thanks for your report
--
Alexandre Oliva http://www.dcc.unicamp.br/~oliva aoliva@{acm.org,computer.org}
oliva@{dcc.unicamp.br,gnu.org,egcs.cygnus.com,samba.org}
Instituto de Computação, Universidade Estadual de Campinas, SP, Brasil
More information about the Gcc-bugs
mailing list