SDL_MAIN_NEEDED(3)

πŸ“¦
version 3.4.18 Β· 5 versions
, in fedora 43, fedora 44

πŸ’– NAME πŸ’–

SDL_MAIN_NEEDED β€” bestie, this one's a macro that's only defined when your target platform literally requires a special mainline through SDL. Like, no mainline through SDL, no vibes. πŸ‘‘


✨ SYNOPSIS ✨

#include <SDL3/SDL_main.h>

#define SDL_MAIN_NEEDED

🌸 DESCRIPTION 🌸

Okay so, plot twist: if your platform doesn't need it, this won't be defined at all. Not even a little. It's giving "only shows up when it's needed." πŸ™ˆ

But if it is defined? Then SDL's headers will redefine main to SDL_main. Yes, for real, they just do that. πŸ’…

Also important, iykyk: this macro is defined by SDL_main.h, and SDL_main.h is not automatically included by SDL.h. So if you're out here wondering why you don't see it, that's why, bestie. It's not sneaking in with the rest. πŸ¦‹

And even if your platform does require it, an app can still define SDL_MAIN_HANDLED and provide their own main β€” but only if they know what they're doing. That's the whole caveat, fr fr. Don't come for me if you rawdog it without knowing. 😭

Heads up: this macro is used internally by SDL, and apps probably shouldn't rely on it. It's not yours, it's SDL's, okay? Not me gatekeeping, it's literally in the docs. 🫢

⭐ AVAILABILITY ⭐

This macro has been available since SDL 3.2.0. Iconic behavior, honestly. 🌈


And that's the whole page, angel πŸ’œ β€” brought to you by Simple Directmedia Layer, version SDL 3.4.18, from the SDL3 FUNCTIONS era of the manual. Slay, go forth, and don't touch SDL_MAIN_NEEDED unless you must. Periodt. πŸŽ€βœ¨

πŸ“¦ where this page comes from