Global ptrs init to NULL or 0000?

Mike Banahan mikeb at inset.UUCP
Fri Nov 15 21:24:07 AEST 1985


In article <139200016 at uiucdcsb> kenny at uiucdcsb.CS.UIUC.EDU writes:
>
>OK, so what does
>
>static union {
>	int i;
>	char *p;
>	} foo;
>
>get initialized to on a machine with a non-0 NULL?  Incidentally, something
>like this appears in a LOT of UN*X programs, and is a MAJOR headache in
>attempting to port to a machine with a non-0 NULL.

This is an example of an initialised union; explicit initialisation of unions
is not permitted in X3J11. Almost quoting the draft standard ``static objects
not initialised explicitly are initialised as if every *scalar* member
were assigned the integer constant 0 ''.

Now a union is not a scalar object. But its members would seem to be.
Perhaps herein lies an ambiguity.

-- 
Mike Banahan, Technical Director, The Instruction Set Ltd.
mcvax!ukc!inset!mikeb



More information about the Comp.lang.c mailing list