Functions within structures
Larry Jones
scjones at thor.UUCP
Wed Nov 14 12:04:34 AEST 1990
In article <14431 at smoke.brl.mil>, gwyn at smoke.brl.mil (Doug Gwyn) writes:
> [ about whether "(*pf)() or (pf)() is more correct ]
>
> Actually the second one is more "theoretically" correct. The function
> designator in the first expression is automatically converted to a
> pointer to the function; the second form is already that way.
That depends on which theory you subscribe to. In classic C, you called
a function -- there was no automatic conversion to a pointer -- and the
first form was thus "theoretically" correct. The second form was, at
least for some compilers, "completely" wrong -- they refused to generate
code when presented with that construct.
Of course, we all know that you use the address to call a function so
it makes much more sense to say that a call is made using a pointer to
the function and having the name of a function decay into a function
pointer like the name of an array decays into a pointer to the first
element. That's precisely what X3J11 did, although both decays were
generalize to expressions of the specified type rather than special
casing names.
----
Larry Jones UUCP: uunet!sdrc!thor!scjones
SDRC scjones at thor.UUCP
2000 Eastman Dr. BIX: ltl
Milford, OH 45150-2789 AT&T: (513) 576-2070
Don't you hate it when your boogers freeze? -- Calvin
More information about the Comp.lang.c
mailing list