This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: Macro expansion with "..."
- To: Giuliano Procida <GProcida at Madge dot com>
- Subject: Re: Macro expansion with "..."
- From: Alexandre Oliva <oliva at dcc dot unicamp dot br>
- Date: 03 Mar 1999 03:30:45 -0300
- Cc: "'egcs-bugs at cygnus dot com'" <egcs-bugs at cygnus dot com>
- References: <4110BC526A58D211B56C0000F6B9636D8CBB24@ws-exch01.dev.madge.com>
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