SDL_CreateThread(3)
π SDL_CreateThread π
okay bestie, welcome to the SDL3 FUNCTIONS corner of the SDL_CreateThread(3) page β yes that's the manual name, we're keeping it, it's iconic. let's get you a whole new thread fr fr π§΅β¨
β¨ NAME β¨
SDL_CreateThread β spin up a brand new thread with a default stack size. that's it, that's the whole vibe. π¦
πΈ SYNOPSIS πΈ
#include <SDL3/SDL_thread.h>
SDL_Thread * SDL_CreateThread(SDL_ThreadFunction fn, const char *name, void *data);
π DESCRIPTION π
so this one is a convenience function, meaning it's literally equivalent to calling SDL_CreateThreadWithProperties but with these properties already set for you:
SDL_PROP_THREAD_CREATE_ENTRY_FUNCTION_POINTER:fnSDL_PROP_THREAD_CREATE_NAME_STRING:nameSDL_PROP_THREAD_CREATE_USERDATA_POINTER:data
and now the plot twist π β this "function" is actually a macro that calls an internal function with two extra parameters that aren't listed here. they're hidden behind preprocessor macros, and they exist to support various C runtimes right at the point of the function call. so if you're writing language bindings and you're not using the C headers, you're gonna have to deal with that yourself. sorry babe, that's just the lore. π
but usually? apps should just call this function the same way on every platform and let the macros handle the details. no cap, that's the move. π
π FUNCTION PARAMETERS π
fnβ theSDL_ThreadFunctionfunction that gets called in the new thread. the main character of your thread's whole storyline. βnameβ the name of the thread. give it a cute one. π·οΈdataβ a pointer that gets passed tofn. π
π RETURN VALUE π
on success it returns an opaque pointer to the new thread object. if the new thread couldn't be created you get NULL instead β and in that case, go call SDL_GetError() for more info, she'll tell you what went wrong. π
π₯ THREAD SAFETY π₯
it is safe to call this function from any thread. yes, any. go off. π―
β AVAILABILITY β
this function is available since SDL 3.2.0. vintage-ish but make it fresh. β¨
π SEE ALSO π
and that's the whole page, bestie!! π«Ά this little love letter to SDL_CreateThread(3) came to you straight from Simple Directmedia Layer, SDL 3.4.18 β mwah, go forth and spawn threads responsibly ππ§πΈ
π¦ where this page comes from
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms