On Thursday, 12. February 2009 16:14:23 Jan Engelhardt wrote: > >1. Other people which don't know this "trick" will think > >the variable is not initialized -> Hard to read. > > Well, maybe then they should get a better C book -- > automatic initialization is said to be(*) part of the C standard. > And one should know the standard of a language IMHO. > > (*) Because it is not free, it remains a saga from people who do > have access to it. :p That is completly true. OTOH avoid the dark corners of the language. > >2. If that variable gets moved f.e. inside a function, it will become > >uninitialized. Also I'm not sure if the savings are even measurable... > > It seems to be for the Linux kernel. Especially when you happen > to have large globals (both a lot of them, and large; e.g. > foo[NR_CUPS]) this becomes a concern. Well, I guess that's a job for the compiler/optimizer. I did a quick test by writing two versions of a small program initializing a static variable with zero and one version that doesn't (=zeroed in .bss). Guess what, the size of the resulting executable stays the same. When I initialize the variable with a non-zero value, then the program size increases. I tested "-O2", "-O0" and "-Os" and the results where the same. Feel free to look at the assembler output, though I guess this optimization is not measurable and makes the code harder to read :o) Thomas -- To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html