Il 23/08/2012 13:46, rbmj ha scritto: > On 8/23/2012 4:24 AM, Paolo Bonzini wrote: >> Some comments on the patches: >> >>> + c_fix_arg = "%0\n" >>> + "#define ioctl(fd, func, arg) ((ioctl)((fd), (func), >>> ((int)(arg))))\n"; >> This can be simply >> >> #define ioctl(fd, func, arg) ioctl(fd, func, (int)arg) >> >> thanks to C and cpp precedence rules. > > OK. I just over-parenthesize all function-macros by default because I > can never remember the rules exactly and worry about not anticipating > what someone puts in a macro. >>> + c_fix_arg = "%0\n" >>> + "#ifdef IN_GCC\n" >>> + "#define mkdir(dir, mode) ((mode), (mkdir)(dir))\n" >>> + "#endif\n"; >> Are you sure about the #ifdef/#endif? In fact, you definitely do not >> want a _global_ include to have a dependency on a user symbol. > The idea is I don't want to break existing code, so I only want this > macro to take effect inside of GCC proper, as (AFAIK) anything built > with the new compiler gets the fixed includes, and there's lots of > VxWorks code that relies on single-argument mkdir. > The alternative is varaidic macros, but I'm no expert on the nuances of > c89 vs c99 variadic macros.
Something like this should work: #define mkdir(dir, ...) ((void)0, ##__VA_ARGS, (mkdir)(dir)) >>> Subject: [PATCH 10/10] Make open() call more compatible in gcc/gcov-io.c >>> >>> In gcc/gcov-io.c, the call to open() only has two arguments. This >>> is fine, as long as the system open() is standards compliant. >> So you have to add another fixincludes hack, adding a macro indirection >> like the one you have for ioctl: >> >> #define open(a, b, ...) __open(a, b , ##__VA_ARGS__, 0660) >> #define __open(a, b, c, ...) (open)(a, b, c) > > Again, just not sure about variadic macro compatibility. If that will > work for both c89 and c99 and c++, then that looks good to me. Yes, GCC has variadic macros as an extension in C89 mode too. You need to experiment a bit with -pedantic and/or -ansi and/or -std=c89, though. Paolo