SDL_ThreadFunction(3type)

πŸ’– SDL_ThreadFunction πŸ’–

okay bestie, welcome to the SDL_ThreadFunction(3type) page β€” it's a datatype situation, part of the SDL3 datatypes era, and honestly? it's giving "tiny but crucial" πŸ’…


✨ NAME ✨

SDL_ThreadFunction β€” the function you hand over to SDL_CreateThread() so it can be the entry point of your brand new thread. like, it's literally the first thing your baby thread does with its life πŸ¦‹


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_thread.h>

typedef int (SDLCALL *SDL_ThreadFunction) (void *data);

look at that signature. look at it. int return, void *data in, SDLCALL doing its little calling-convention moment. iconic, no notes πŸ‘‘


πŸŽ€ FUNCTION PARAMETERS πŸŽ€

  • data β€” literally just whatever you passed as data to SDL_CreateThread(). that's it, that's the whole vibe. it comes back to you here, same as you sent it πŸ’«

⭐ RETURN VALUE ⭐

you return a value, and that value can get reported back out through SDL_WaitThread(). so like… your return value isn't shouting into the void, it gets picked up later. main character energy fr fr πŸ™ˆ


🌈 AVAILABILITY 🌈

this datatype has been available since SDL 3.2.0. so if you're on anything older, bestie, it's not here yet 😭


lowkey reminder: keep that signature exact. int, SDLCALL, void *data. don't get creative with it, the compiler will absolutely clock you πŸ’€

mwah πŸ’‹ that's the whole page. written up by the lovely folks over at Simple Directmedia Layer, tagged SDL 3.4.18, and filed under SDL_ThreadFunction(3type) β€” go make some threads, you absolute icon 🫢✨

πŸ“¦ where this page comes from