specifically in the bss section
learn something new every day!
they never mentioned that optimization in systems programming class! <g>.
specifically in the bss section
learn something new every day!
they never mentioned that optimization in systems programming class! <g>.
It took so long to run the pre-main initialization that we could not pass certification as-is. We had to hack in to the runtime and display the splash screen. Rather than the normal sleep while a splash was running, it spent those seconds initializing variables and doing other pre-main work.
OMG! LOL!
so it had a ton of global instances with custom constructor code that took many seconds before you got control in main() ? <g>
i had to "hack in" a loading splash screen for caveman too. the game does a one time load of all assets at program start, about 10-20 seconds - after that, no load screens whatsoever. when i switched from d3dx fonts to a custom font using d3dx sprites for speed, i found i no longer had a font available for loading progress messages. i had to temporarily load in a splash screen. the only non sequential vidram allocation in the whole game. and its the first one! i really should fix that. make it texture #0, the first texture loaded, and move texture #0 (grass tile #1) to the end of the list. but then i have a 1024x1024 sitting at the base of graphics ram the whole game for no reason. but right now, it loads the splash screen, then it loads everything else, then frees the splash screen. so i have nice contiguous ram, with a 1024x1024 hole at the start! <g>.
If a variable is global, or if a variable is a static member-variable of a class (which is just a global variable in the class's namespace), then you can't count on the order or timing of when they are constructed. The only thing you can depend on is that they'll be constructed before int main() enters... but other than that, the order is compiler-specific.
You can't count on the initialization of globals defined in different translation units. Globals defined in the same translation unit are well defined to initialize in the order they are found. Not that that helps much.