C oddity -- language and/or compiler

utzoo!decvax!harpo!seismo!hao!menlo70!sytek!zehntel!tektronix!tekmdp!bronze!grahamr utzoo!decvax!harpo!seismo!hao!menlo70!sytek!zehntel!tektronix!tekmdp!bronze!grahamr
Wed Jan 19 09:46:29 AEST 1983

PCC goes along with the reference manual where the Ritchie compiler
doesn't.  I don't have a white book page number, but in section 10
of the paper "The C Programming Language -- Reference Manual" (I
think this paper appears as an appendix to the white book), note:

	A C program consists of a sequence of external definitions.
	An external definition declares an identifier to have
	storage class extern (by default) or perhaps static, and a
	specified type.  The type-specifier (sec. 8.2) may also be

Also, note that in the entries in the syntax summary (sec. 18.4) the
only part of these external definitions that is required is the semicolon!
	program : external-definition
	external-definition : data-definition
	data-definition : EXTERN[opt] type-specifier[opt]
		init-declarator-list[opt] ;

PCC is the only compiler I know of which actually performs correctly.
Your example:

double a;

declares a to be "extern double" and b, c, and d to be "extern int".
In the VAX code for "main(){a=b;}" note that an integer-to-floating
conversion is done:

_main:	.word	L16
	cvtld	_b,r0
	movd	r0,_a

	- Graham Ross, Tektronix

More information about the Comp.lang.c mailing list