Global ptrs init to NULL or 0000?
Henry Spencer
henry at utzoo.UUCP
Tue Nov 5 11:21:23 AEST 1985
> ... in all the C compilers I know of, any uninitialized
> global/static is stuffed into the bss section and is set to all 0 bytes at
> run time...
>
> So the big question is: is it OK (portable, etc) to assume that declaring
> a global/static ptr without initialization will set it to the machine's
> idea of NULL, not all 0 bytes? ...
That's the way things are supposed to work according to X3J11. I would be
a little wary of assuming that things really *do* work that way on those
few machines that have non-0 NULLs, with current compilers. I'd say the
assumption is all right in general, unless you are really being maximally
paranoid. If you expect to have to port your software to such a machine
next month, some paranoia may be in order.
--
Henry Spencer @ U of Toronto Zoology
{allegra,ihnp4,linus,decvax}!utzoo!henry
More information about the Comp.lang.c
mailing list