This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
rfc: macros accepting constructors
- From: Aldy Hernandez <aldyh at redhat dot com>
- To: jason at redhat dot com, gcc at gcc dot gnu dot org
- Cc: geoffk at redhat dot com
- Date: Wed, 26 Jun 2002 00:41:54 -0700
- Subject: rfc: macros accepting constructors
hi guys.
[jason, we had talked about this a while back, and the problem has come
back to haunt me ;-)].
iso C stipulates that macros accepting arguments are grouped only by
parentheses. so the code below, will fail because we think foo()
is receiving 4 arguments instead of 1.
#define foo(x) bar((x))
foo((vector int){0, 1, 2, 3});
main a.c:7:31: macro "foo" passed 4 arguments, but takes just 1
the interesting thing is that this does not only affect vectors, but
arrays, structures, and other aggregate types. since ANSI C allows
for library functions to be macros, any such macros will fail if we
pass aggregates as above.
the cleanest solution i can think of is modifying the preprocessor to
allow grouping with curlies as well. can anyone think of a better
solution?
aldy