Initializing Vars in non-OS C systems

chris at umcp-cs.UUCP chris at umcp-cs.UUCP
Sat Jul 23 16:24:33 AEST 1983


Since the thing that started this discussion was Whitesmith C, let me
point out yet again that the problem is not that they don't set statics
to zero.  They *do* set statics to zero -- try

	main () { static x; putfmt ("x=%d\n", x); }

and you get zero (I forget if you use putfmt that way, but you probably
understand what I mean).  The problem is that they don't create a
global variable unless you initialize it!  Try

	int var;
	main () { foo (var); }
	foo (n) int n; { }

Compile, and you get:  "Undefined: var.".  If you use

	int var = <any integer> ;

it compiles correctly.  But if you don't initialize it it's considered
*external*.

				- Chris
-- 
In-Real-Life:	Chris Torek, Univ of MD Comp Sci
UUCP:		{seismo,allegra,brl-bmd}!umcp-cs!chris
CSNet:		chris at umcp-cs
ARPA:		chris.umcp-cs at UDel-Relay



More information about the Comp.lang.c mailing list