---
name: "SDL_main"
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_main"
---

# SDL\_main(3)

An app-supplied function for program entry.

## NAME

SDL\_main - An app-supplied function for program entry.

## HEADER FILE

Defined in SDL3/SDL\_main.h

## SYNOPSIS

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

**int SDL\_main(int argc, char \*argv\[\]);**

## DESCRIPTION

Apps do not directly create this function; they should create a standard ANSI-C **main** function instead. If SDL needs to insert some startup code before **main** runs, or the platform doesn't actually \_use\_ a function called "main", SDL will do some macro magic to redefine **main** to

**SDL\_main** and provide its own **main** .

Apps should include **SDL\_main.h** in the same file as their **main** function, and they should not use that symbol for anything else in that file, as it might get redefined.

This function is only provided by the app if it isn't using

**SDL\_MAIN\_USE\_CALLBACKS** .

Program startup is a surprisingly complex topic. Please see \[README/main-functions\](README/main-functions), (or docs/README-main-functions.md in the source tree) for a more detailed explanation.

## FUNCTION PARAMETERS

- *argc*

  an ANSI-C style main function's argc.

- *argv*

  an ANSI-C style main function's argv.

## RETURN VALUE

Returns an ANSI-C main return code; generally 0 is considered successful program completion, and small non-zero values are considered errors.

## THREAD SAFETY

This is the program entry point.

## AVAILABILITY

This function is available since SDL 3.2.0.
