In file src.cpp
void initz()
{
// ...
}
I want execute this function when the .exe start,before 'int main()', so i use
void initz()
{
// ...
}
initz();
but it can't compile success. I know i can use
int initz()
{
// ...
}
static int a = initz();
but this will create a new variable 'a', although it will not add a new symbol to the linker(can't use outside the .obj file) .but it seems not a good solation.
very important How to avoid create the new variable 'a'? I don't want to use anymore memory space to execute the function. i think it's no necessory.