This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: rfc: macros accepting constructors
- From: Tim Hollebeek <tim at hollebeek dot com>
- To: Joern Rennecke <joern dot rennecke at superh dot com>
- Cc: Andreas Schwab <schwab at suse dot de>, Aldy Hernandez <aldyh at redhat dot com>, jason at redhat dot com, gcc at gcc dot gnu dot org, geoffk at redhat dot com
- Date: Thu, 27 Jun 2002 12:28:02 -0400
- Subject: Re: rfc: macros accepting constructors
- References: <3D1B3BDE.3956A494@superh.com>
- Reply-to: tim at hollebeek dot com
On Thu, Jun 27, 2002 at 05:22:54PM +0100, Joern Rennecke wrote:
> >Aldy Hernandez <aldyh@redhat.com> writes:
> >
> >|> the cleanest solution i can think of is modifying the preprocessor to
> >|> allow grouping with curlies as well.
>
> It would if that grouping is only enabled for macros that are
> defined in a way that is non-standard or invokes implementation-defined
> behaviour.
> E.g. we could precede the macro definition with a
> #pragma gcc initializer_argument ,
> or have some funky syntax for the macro definition, like:
>
> #define foo({x}) bar((x))
How gross.
Perhaps the best suggestion (if anything is desirable) is to modify
grammar so that ()'s are allowed around any grammar element which is
surrounded by {}'s. Then all you have to do is remember to use ({ and
}) whenever you want to use {...,...,...} inside a macro.
Silly example:
#define func(name, body) void name(void) body
func(foo, ({ int x, y; }))
==>> void foo(void) ({ int x, y; })
== void foo(void) { int x, y; }