"a();" not a valid external declaration in pANS C.

Joe Buck jbuck at epimass.EPI.COM
Tue Feb 7 03:51:32 AEST 1989


In article <46 at microsoft.UUCP> jangr at microsoft.UUCP (Jan Gray) writes:
>pANS C accepts "int a();" and "a() {}" but not "a();", which is valid K&R C.
>I am curious about the rationale behind this change.  Was it "nobody really
>uses that construct, and banning it simplifies the grammar"?

Not only does nobody use that construct intentionally, but I've seen
problems arise because of typos because of this construct.  I had a
coworker make an error roughly equivalent to

double x, y; func();

(typing a semicolon instead of a comma) which has the effect of
declaring func to return an integer (this is easy to do when you add
an extra variable or function to a declaration).  Under ANSI rules an
error is reported and the problem is corrected.

-- 
- Joe Buck	jbuck at epimass.epi.com, or uunet!epimass.epi.com!jbuck,
		or jbuck%epimass.epi.com at uunet.uu.net for old Arpa sites

Life is not a dress rehearsal.



More information about the Comp.std.c mailing list