John Love-Jensen wrote:
...is there a warning flag (for C) in either gcc 3.4.4 or 4.x to warn
about using 'foo' (as opposed to 'foo()' or '&foo')?
Both foo and &foo are function pointers to the foo() function.
The &foo is superfluous, but allowed.
"Allowed", yes, except that '&foo' makes it clear you wanted... well,
'&foo', as opposed to forgetting the '()'s on 'foo()'. This would be
/especially/ relevant if foo was "fp foo() { ... }" (i.e. returns a
function pointer) instead of "void foo() { ... }". Although I guess
-Wbad-function-cast would in theory catch this sort of error, since I
can't think of a way to declare a function pointer type that returns a
function pointer type that returns a function pointer type that... ad
infinum. (Especially since such a thing wouldn't make sense; how would
you use it?)
Anyway, I read somewhere that omitting the '&' is deprecated/unsupported
for some language (i.e. might've been C++, or even Java) and/or standard
and/or compiler. Because I agree with the sentiment (it's nice for
readability also), I was hoping gcc could help enforce use of this syntax.
--
Matthew
GDRLaH - Grin, Duck, and Run Like a Hippo! :-)