On Tue, 9 Jan 2001, Eric Pouech wrote:
> > I think this is beyond winemaker's scope. It would require parsing
> > the file, detecting that a macro is defined and then called with a
> > different number of arguments, then going back and changing the macro
> > definition...
> > It seems to complex, and thus too likely to fail, to me. Also it does
> > not seem to be something very common that would make it really
> > worthwhile. It's not like the case issues or the pack issues which occur
> > many times in many applications.
> well, I just had in mind to test for macros defined as
> #define macro()
But the above is absolutely valid C code.
> and replace it by #define macro (void)
This too is valid C code. It's a macro that takes exactly one
argument called void.
> (or #define macro(...) for gcc)
And this is valid C99 code. It's a vararg macro and is yet something
else. Also it's not very portable.
Two additional facts to bear in mind:
- it's not just 0-parameter macros that are affected
- such constructions generate warnings on Windows too
For example test the following snippet. You'll get a warning on
all but the first invocation of 'foo'.
#define foo(a,b) (a)+(b)+1
...
foo(a,b);
foo();
foo(a);
foo(a,b,c);
Even making 'foo' a vararg macro will not solve the problems of using
it with fewer parameters than have been declared.
So doing the right thing is non-trivial. Since the compiler will give
an error, I think it's better to let it do its job of telling the user
something is wrong.
--
Francois Gouget [EMAIL PROTECTED] http://fgouget.free.fr/
May your Tongue stick to the Roof of your Mouth with the Force of a Thousand Caramels.