In a C/C++ program how does the system (windows, linux, mac OS X) call the main() function

前端 未结 7 1482
半阙折子戏
半阙折子戏 2020-12-09 03:51

I am looking for a more technical explanation then the OS calls the function. Can anyone help me out or point me to a website or book?

相关标签:
7条回答
  • 2020-12-09 04:53

    As far as windows goes, the entry point functions are:

    • Console: void __cdecl mainCRTStartup( void ) {}
    • GUI: void __stdcall WinMainCRTStartup( void ) {}
    • DLL: BOOL __stdcall _DllMainCRTStartup(HINSTANCE hinstDLL,DWORD fdwReason,void* lpReserved) {}

    The only reason to use these over the normal main/WinMain/DllMain is if you wanted to use your own run time library (If you want smaller file size or custom features)

    For custom run time implementations and other tricks to get smaller PE files, see:

    • http://www.microsoft.com/msj/archive/S569.aspx
    • http://www.codeproject.com/KB/tips/aggressiveoptimize.aspx
    • http://www.catch22.net/tuts/minexe.asp
    • http://www.hailstorm.net/papers/smallwin32.htm
    0 讨论(0)
提交回复
热议问题