---
name: "SDL_RunApp"
section: "3"
platform: "linux"
package: "libsdl3-doc"
version: "3.2.10+ds-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/SDL_RunApp"
---

# SDL\_RunApp(3)

Initializes and launches an SDL application, by doing platform-specific initialization before calling your mainFunction and cleanups after it returns, if that is needed for a specific platform, otherwise it just calls mainFunction.

## NAME

SDL\_RunApp - Initializes and launches an SDL application, by doing platform-specific initialization before calling your mainFunction and cleanups after it returns, if that is needed for a specific platform, otherwise it just calls mainFunction.

## HEADER FILE

Defined in SDL3/SDL\_main.h

## SYNOPSIS

```
#include "SDL3/SDL.h"
```

**int SDL\_RunApp(int argc, char \*argv\[\], SDL\_main\_func mainFunction, void \*reserved);**

## DESCRIPTION

You can use this if you want to use your own main() implementation without using  **SDL\_main**\
  (like when using

**SDL\_MAIN\_HANDLED** ). When using this, you do *not* need

**SDL\_SetMainReady** ().

## FUNCTION PARAMETERS

- *argc*

  the argc parameter from the application's main() function, or 0 if the platform's main-equivalent has no argc.

- *argv*

  the argv parameter from the application's main() function, or NULL if the platform's main-equivalent has no argv.

- *mainFunction*

  your SDL app's C-style main(). NOT the function you're calling this from! Its name doesn't matter; it doesn't literally have to be **main** .

- *reserved*

  should be NULL (reserved for future use, will probably be platform-specific then).

## RETURN VALUE

Returns the return value from mainFunction: 0 on success, otherwise failure;  **SDL\_GetError** () might have more information on the failure.

## THREAD SAFETY

Generally this is called once, near startup, from the process's initial thread.

## AVAILABILITY

This function is available since SDL 3.2.0.
