On 2013-10-22, Dave Angel <da...@davea.name> wrote: > On 22/10/2013 08:00, Steven D'Aprano wrote:
>> [quote] >> C does not require you to set static global arrays to ?0?, so the >> for loop in the main function can go... >> >> Wait a minute... Haskell, I'm pretty sure, zeroes memory. C doesn't. So > > Static int variables are in fact zeroed. However, most C compilers > do it by putting four bytes (or whatever) into the image of the > executable so it has no runtime cost. No, that's not how gcc works (nor is it how any other C compiler I've ever seen works). Static variables get located in a "bss" section[1], which is zeroed out at run-time by startup code that gets executed before main() is called. The ELF executable contains headers that describe the size/location of bss section, but the object file contains no actual _data_. [1] IIRC, the name "bss" is a historical hold-over from the PDP-11 assembler directive that is used to declare a section of memory that is to be filled with zeros. Not all compilers use that section name, but they all use the same mechanism. > int myvar = 34 * 768; > > it'll put the product directly in the executable image, and no > runtime code is generated. That is true. -- Grant Edwards grant.b.edwards Yow! My EARS are GONE!! at gmail.com -- https://mail.python.org/mailman/listinfo/python-list