Search code examples
cstartupmsvcrt

C functions before mainCRTStartup on Mingw?


void start() {
stuff(); //code before mainCRTStartup
mainCRTStartup();
}
int main()
{
//other code
}

In Visual C++,it compiles fine and function "stuff()" gets called before main. How would call "stuff()" before "mainCRTStartup()"? on Mingw(OS:Windows NT)? it seems to ignore "void start()".


Solution

  • You could use the -e argument to ld (the linker) to specify start as your entry point.

    I'm not sure how to feed arguments to ld using mingw; perhaps someone can edit my answer to provide that.