I am trying to ensure a function will get called first by the program to ensure the initizilation of critical objects. However, I am confused as to how init_seg is suppose to be getting used/called.
For example, from the documentation at msdn it would seem as if the following would be the first to be called.
#pragma init_seg( ".CRT$XCC" )
static void InitializeStuff()
{
printf("InitializeStuff\n");
}
However, that does not seem to be the case as that function will just plainly not get called automatically (unless I call it explicitly, of course).
How can I use init_set to ensure a function is called before the rest of my other executing code?
If i have understood it right you place all global variables that you want to be initialized first in the same file as the
#pragma init_segExample:
And make sure you dont place any other globals in that file than the ones you want to initialized first.