Where is the definition for main()?

I’m interested to see how UE4 handles main() internally. It must have one just like any other C++ application. If not, then how does this work?

The classic main function can be found in the Launch module in Engine\Source\Runtime\Launch.

There it depends on the platform.

For Windows You have LaunchWindows.cpp where is the

int32 WINAPI WinMain( HINSTANCE hInInstance, HINSTANCE hPrevInstance, char*, int32 nCmdShow )

For iOS You have LaunchIOS.cpp with the

int main(int argc, char *argv[])

You can also check the IOSAppDelegate.cpp from the Core module, where the most important Objective-C stuff is done.

For Android there is LaunchAndroid.cpp with

void android_main(struct android_app* state)

This one is little tricky, because it uses the native c++ NDK to work.

Unfortunatelly I don’t have experience with other platforms.

I know the answer only scratch the surface how UE4 rolls, but I think this is good place to start.

But in fact, unless You don’t want to modify the core of the Engine You don’t have to bother about it.

1 Like

so awesome

1 Like