Re: [cc65] BSS Segment

Date view Thread view Subject view

From: Ullrich von Bassewitz (uz_at_musoftware.de)
Date: 2003-08-26 00:08:02


On Mon, Aug 25, 2003 at 09:38:07PM +0200, Groepaz wrote:
> wow, i didnt know that... i've worked with a bunch of machines now and never
> stumbled over one were zeroing out bss would not be the right thing to do....

Yes, but the thing where most people get a hickup is that

        char* p = 0;

does not assign a bit pattern of all zeroes to p. Instead, "0" is converted to
the NULL pointer constant of the machine, may it be something consisting of
all zero bits or not.

> have an example handy where it would have been wrong by any chance?

I don't have any examples handy, but

        http://www.eskimo.com/~scs/C-faq/s5.html

for english readers, and

        http://www-info2.informatik.uni-wuerzburg.de/dclc-faq/kap1.html

for german readders will give an introduction.

As an additional hint, the above is the reason why calloc() is non portable.
It will write binary zeroes to the allocated memory, but sicne this will not
set pointers to NULL and floats to 0.0 on all platforms, it should be avoided.

Regards


        Uz


-- 
Ullrich von Bassewitz                                  uz_at_musoftware.de
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo_at_musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.


Date view Thread view Subject view

This archive was generated by hypermail 2.1.3 : 2003-08-26 00:08:50 CEST