ptrs to functions

Mark Plotnick mp at mit-eddie.UUCP
Mon Aug 22 08:26:49 AEST 1983

This addresses-of-arrays business made me wonder what happens
when you try to pass functions as parameters.  Now, all you
people who grew up with the V7 C compiler know that, in order
to pass a function as a parameter, all you need do is mention
the function's name in the actual parameter list.  The declaration
of the formal would look something like "int (*func)();", and to
invoke it you'd do something like "j = (*func)(i)".

With 4.1bsd pcc, the rules are a bit lax.  You can declare a
formal as "int func();" and only get a mild warning.  You can
even do "j = func(i)" and get no warning at all.  In both cases,
func is really a pointer to the function.

I'm not going to take a stand as to whether or not the pcc rules
violate the definition of C; after all, the most recent C
reference manual is from 1979 or so, and who knows what's
changed since then.  But pcc's extensions make the job of
porting code to V7 a pain, sometimes.

	Mark (genrad!mit-eddie!mp, eagle!mit-vax!mp)

More information about the Comp.lang.c mailing list