Possible duplicate:does gcc automatically initialize static variables to zero?
Are statically declared objects inside a function guaranteed initialization with 0?
0
For instance:
int func(void) { static int x; ... }
The standard promises that the x = 0first call func()?
x = 0
func()
C99 Standard says:
5.1.2 runtime... All objects in the static storage must be initialized (set to their initial values) before the program starts.
5.1.2 runtime
... All objects in the static storage must be initialized (set to their initial values) before the program starts.
, , static , " " 0 .
static
, .
, .bss , , main.
.bss
main
. , :
gcc ?
Yes, it is initialized to zero. But, however, it would be nice to use static method variables in general. C # clearly avoided confusion and refused to support static method variables.
http://blogs.msdn.com/b/csharpfaq/archive/2004/05/11/why-doesn-tc-support-static-method-variables.aspx
All static variables are stored in the Datasection in the memory section, where all variables are set to default values.