I have a question about the initialization of global variables:
If I define in one .cpp-file "int a = 12" and then declare in the .cpp-file with the main function "extern int a", is it guaranteed by c++-standard that "int a" was initialized before entering main()? Or could it happen that "int a" is initialized with 0 at use, because the statics initialization of the other cpp-file wasn't executed?
The global is always correctly initialized across several files with my compiler (gcc), but I'd like to know if it's defined to happen that way.
And yes, I know that globals are evil.![]()



LinkBack URL
About LinkBacks



