K&R App A, par. 8 & 8.2, on Declarat

kah at hpfclq.UUCP kah at hpfclq.UUCP
Sun Jul 8 23:59:00 AEST 1984


Re: whether 
	a =1;
can be a legal declaration.

See K&R, Appendix A, 18.3 and 18.4.  Note that the "declaration-list"
productions you reference refer to statements -- ie, declarations
within a function-definition.  And here it is necessary to have either
an sc-specifier or a type-specifier in order to distinguish a declaration
statement from an expression statement.

However, at the global level, declarations are data-definition's (see 18.4),
and here both the type-specifier and (extern | static) are optional.
So
	x;
	y = 1;
are legal external data-definitions
and are equivalent to
	int x;
	int y = 1;
respectively.

K.Harris
hpfcla!kah



More information about the Comp.lang.c mailing list