Messages in this thread | | | Date | Sun, 26 Nov 2000 09:11:18 +1100 | From | Herbert Xu <> | Subject | Re: [PATCH] removal of "static foo = 0" |
| |
Andries Brouwer <aeb@veritas.com> wrote: > > int foo = 0; /* just for gcc */
> when the initialization in fact is not necessary.
Only for non-static foo.
> It is a bad programming habit to depend on this zero initialization. > Indeed, very often, when you have a program that does something > you need to change it so that it does that thing a number of times. > Well, put a for- or while-loop around it. But wait! The second time > through the loop certain variables need to be reinitialized. Which ones? > The ones that were initialized explicitly in your first program. > Make the program into a function in a larger one. Same story.
Again, this only applies to non-static variables. For static ones, they're initialised once only even when they go out of scope.
> Saving a byte in the binary image is not very interesting. > Preserving information about the program is important.
No information is lost. -- Debian GNU/Linux 2.2 is out! ( http://www.debian.org/ ) Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org Please read the FAQ at http://www.tux.org/lkml/
| |