> > 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.
nope... 
#define macro (void)
is a macro defined without arguments. So 
macro(1, 2, 3); 
is translated into 
(void)(1, 2, 3);
which can be optimized out into nothing.

As a matter of fact, 
- using #define DPF() generates errors with gcc and lcc
- using #define DPF (void) generates warnings on lcc (unused statement), and
is ok on gcc

(DPF(...) would be valid on gcc as you noticed, but not very portable)

so my point is just to replace macro with no parameters and no body with (void)
this perl code should do

if ($_ =~ /^[ \t]*#define[ \t]*+([a-zA-Z_][a-zA-Z0-9_]*)\([ \t]*\)[ \t]*$/o) {
        print "#define $1 (void)\n";
}

A+
-- 
---------------
Eric Pouech (http://perso.wanadoo.fr/eric.pouech/)
"The future will be better tomorrow", Vice President Dan Quayle

Reply via email to