Function pointer syntax peculiarity

Chris Torek chris at umcp-cs.UUCP
Fri Nov 30 07:29:12 AEST 1984


I think this has been mentioned before.  PCC accepts almost anything as
a function.  Try

	f(g)
	int (*g)();
	{
		(**********g)(1);
	}

for example.

I personally think it makes perfect sense to say

	f(g)
	int (*g)();
	{
		g(1);
	}

but this breaks the nice consistency between the way a variable is
declared and the way it is used.  (It makes sense since a function
name by itself is a pointer to that function; that is, I write

	main()
	{
		int (*f)();
		int foo();

		f = foo;	/* &foo is wrong */
		foo(6);
		(*f)(6);	/* but f(6) is wrong too */
	}

If & and * are inverses, I should be saying either "f = &foo" or
"f(6)", and I should be able to say "(*(&foo))(6)".)

However, "(*f)(<args>)" is correct, and it's a bug/feature that
PCC accepts other forms.
-- 
(This line accidently left nonblank.)

In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (301) 454-7690
UUCP:	{seismo,allegra,brl-bmd}!umcp-cs!chris
CSNet:	chris at umcp-cs		ARPA:	chris at maryland



More information about the Comp.lang.c mailing list