# Where is the definition for main()?

**URL:** <https://forums.unrealengine.com/t/where-is-the-definition-for-main/330821>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [September 2, 2015, 11:27pm UTC](https://forums.unrealengine.com/t/where-is-the-definition-for-main/330821 "2015-09-02T23:27:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_e67e5cd8](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_e67e5cd8](https://forums.unrealengine.com/u/anonymous_user_e67e5cd8)\
**Post date:** [September 2, 2015, 11:27pm UTC](https://forums.unrealengine.com/t/where-is-the-definition-for-main/330821/1 "2015-09-02T23:27:44Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![zompi2](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/zompi2/32/937524_2.png) [@zompi2](https://forums.unrealengine.com/u/zompi2)\
**Post date:** [November 25, 2015, 6:33pm UTC](https://forums.unrealengine.com/t/where-is-the-definition-for-main/330821/2 "2015-11-25T18:33:53Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![monteeys](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/monteeys/32/696037_2.png) [@monteeys](https://forums.unrealengine.com/u/monteeys)\
**Post date:** [March 19, 2022, 6:41pm UTC](https://forums.unrealengine.com/t/where-is-the-definition-for-main/330821/3 "2022-03-19T18:41:09Z")

</div>

so awesome
