indirect reference/use of procedures
Peter Klausler
pmk at craycos.com
Tue Mar 20 02:35:50 AEST 1990
Larry Jones notes:
> Since "everyone knows" that you really use the address of a
> function to call it (not the function itself), and since function
> names usually turn into function pointers, it was far simpler to
> specify that function "objects" "always" turn into function
> pointers and that the function call operator requires a function
> pointer. It does make the call more readable, but it breaks the
> declaration/use symmetry as you noted.
Section 3.2.2.1 says "Except when it is the operand of the sizeof operator or
the unary & operator, a function designator... is converted to an expression
that has type "pointer to function..."", and 3.3.3.2 notes "The unary *
operator denotes indirection. If the operand points to a function, the result
is a function designator." Thus, given a pointer to a function, you can stick
0 or more asterisks in front of the name during a call on the pointer; they're
all irrelevant. Example:
void f (void) { printf ("Hello"); }
void (*p)(void) = &f;
main () { (******************************************************p)(); }
Strange.
-Peter Klausler, writing compilers at Cray Computer Corp. (not Cray Research)
More information about the Comp.lang.c
mailing list