This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]