rfc: macros accepting constructors
Aldy Hernandez
aldyh@redhat.com
Wed Jun 26 01:36:00 GMT 2002
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
More information about the Gcc
mailing list