This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: Bug in cpp macro varargs extension
- To: zack at rabi dot columbia dot edu
- Subject: Re: Bug in cpp macro varargs extension
- From: "Kaveh R. Ghazi" <ghazi at caip dot rutgers dot edu>
- Date: Wed, 3 Mar 1999 12:39:55 -0500 (EST)
- Cc: egcs-bugs at egcs dot cygnus dot com
> From: Zack Weinberg <zack@rabi.columbia.edu>
>
> On Tue, 2 Mar 1999 13:19:50 -0500 (EST), "Kaveh R. Ghazi" wrote:
> > Does anyone use gcc's macro varargs extension? Is is
> >considered usable?
> >
> > I'm having several problems getting correct expansions. I think
> >it boils down to this test case:
> >
> > > #define error1(msg, args...) printf(msg, "foo", ## args)
> > > #define error2(msg, args...) printf("foo", msg, ## args)
> [...]
>
> ## args, where args is an empty rest argument, deletes the `preceding
> sequence of nonwhitespace characters', not the preceding token. You
> want
>
> #define error1(msg, args...) printf(msg, "foo" , ## args)
>
> Yes this is ugly. It's done this way since cpp doesn't know what the
> "preceding token" is. cpp.info says that "we" may consider changing
> it to the preceding token in the future. Presumably this would
> involve a token-based macro expander. I've been thinking about that
> idly. The benefits are not clear, besides making it easier to
> implement C89 Amendment 1 digraphs.
>
> cpplib behaves identically.
>
> zw
Urg, my fault. I didn't catch this when I read the docs
on macro varargs.
Thanks for your help.
--Kaveh
--
Kaveh R. Ghazi Engagement Manager / Project Services
ghazi@caip.rutgers.edu Qwest Internet Solutions