Global variable initialization
-
Till the last day I belived that the global variables gets initialized automatically. But last day while debugging, I found out that the application start from the WinMainCRTStartup() function. And then stepping through that function, I came accross a function like this.
/* * do C++ constructors (initializers) specific to this EXE */ _initterm( __xc_a, __xc_z );
Then I understood that it is inside this function the global variables get initialized. That means the gloabl variable are explicity been initialized. Can any one tell me whats this__xc_a
and__xc_z
variables are? And how the_initterm
is doing the initialization?nave
-
Till the last day I belived that the global variables gets initialized automatically. But last day while debugging, I found out that the application start from the WinMainCRTStartup() function. And then stepping through that function, I came accross a function like this.
/* * do C++ constructors (initializers) specific to this EXE */ _initterm( __xc_a, __xc_z );
Then I understood that it is inside this function the global variables get initialized. That means the gloabl variable are explicity been initialized. Can any one tell me whats this__xc_a
and__xc_z
variables are? And how the_initterm
is doing the initialization?nave
It looks like __xc_a and __xc_z are arrays of function pointers - pointing to initialization functions. _initterm() loops through calling each function in __xc_a ... ? It's in the runtime source code - see crt0dat.c for _initterm() cinitexe.c for __xc_a and __xc_z crtexe.c for the xxxCRTStartup functions Mark
-
It looks like __xc_a and __xc_z are arrays of function pointers - pointing to initialization functions. _initterm() loops through calling each function in __xc_a ... ? It's in the runtime source code - see crt0dat.c for _initterm() cinitexe.c for __xc_a and __xc_z crtexe.c for the xxxCRTStartup functions Mark