Table of Contents

BootstrapNative

Description

tBootstrapNative.cpp contains the entry point for the native platform. Platforms can occasionally have entry points other than main that are unique to their platform. For instance, on Win32, the entry point is WinMain.

Once in the entry point, there are typically startup and shutdown routines that need to be called before and after the main portion of the program. To abstract this out so that native code never has to be written from within the application, this is to be done within the entry point, not within program_main.

Generally, the contract of the entry point is to:

Example

This is an example of what a Win32 entry point that calls program_main might look like.

//The Platform's actual main routine
int __stdcall WinMain(HINSTANCE hInstance,
                      HINSTANCE hPrevInstance,
                      LPSTR lpCmdLine,
                      int nCmdShow)
{
    char	**argv;
    int		argc;
    int		result;
 
    gWin32Instance = hInstance;
 
    // Get argc, argv
    argv = (char**)CommandLineToArgvW(GetCommandLineW(), &argc);
 
    // Call main
    result = (int)program_main((tUInt32)argc, argv);
 
    // Free argv
    LocalFree(argv);
 
    // Return result from main
    return result;
}

Notes