Uninitialized externals and statics.
Henry Spencer
henry at utzoo.uucp
Fri Aug 18 02:22:06 AEST 1989
In article <2128 at infmx.UUCP> dror at infmx.UUCP (Dror Matalon) writes:
> K&R 2.4 say "External and static variables are initialized
>to zero by default, but it is good style to state the initialization
>anyway."
>
> Is this really portable ? I always initialize globals but I want
>to know if I need to change some old stuff that counts on uninitialized
>variables being initialized to zero.
The initialization to zero for external and static variables is a property
of the C language; all definitions of the language agree on this. Any
compiler that does not implement it is broken.
Note that automatic variables (i.e., essentially all variables defined
within a function) do *not* get initialized to anything in particular.
--
V7 /bin/mail source: 554 lines.| Henry Spencer at U of Toronto Zoology
1989 X.400 specs: 2200+ pages. | uunet!attcan!utzoo!henry henry at zoo.toronto.edu
More information about the Comp.lang.c
mailing list