问题
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()".
回答1:
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.
回答2:
The real entry point is always start()
.
start()
calls mainCRTStartup()
that initializes CRT functions and call main()
, so in stuff()
, you can not use CRT functions.
来源:https://stackoverflow.com/questions/7948537/c-functions-before-maincrtstartup-on-mingw