SDLCALL(3)

✨ SDLCALL ✨

okay bestie, gather round, because we're talking about a macro and I promise it's more iconic than it sounds πŸ’…

🌸 NAME 🌸

SDLCALL β€” the macro that sets a function's calling conventions. that's it. that's the whole job. and she does it flawlessly. πŸ‘‘


πŸŽ€ SYNOPSIS πŸŽ€

#include <SDL3/SDL_begin_code.h>

#define SDLCALL __cdecl

yes, that's the whole thing. short queen behavior fr fr πŸ¦‹


πŸ’– DESCRIPTION πŸ’–

so here's the tea: SDL uses this macro on all its public functions, and on any callbacks it defines too. and the reason is chef's kiss β€” this macro guarantees that calling conventions match between SDL and your app, even if the two were built with different compilers or different optimization settings. no cap. it's giving diplomacy. 🀝

now listen, when you're writing a callback function, it is VERY IMPORTANT that you tag it with SDLCALL correctly. like, do not skip this. mismatched calling conventions can cause strange behaviors and they are genuinely difficult to diagnose 😭 β€” you'll be sitting there like "why is my code haunted" and the answer is the missing tag. not me finding out the hard way πŸ™ˆ

and here's the extra evil part: on many platforms, SDLCALL is defined to nothing. so your compiler literally cannot warn you that the tag is missing. zero heads-up. no vibe check. you just have to ✨know✨. so be careful out there. πŸ’€

also β€” this symbol is used in SDL's headers, but apps and other libraries are totally welcome to use it for their own interfaces as well. share the love, share the macro. 🫢

⚠️ real talk: forgetting SDLCALL on a callback won't always yell at you. it'll just quietly ruin your day. tag your callbacks, bestie. periodt.

🌈 AVAILABILITY 🌈

this macro has been available since SDL 3.2.0. so if you're on anything older... it's giving ancient history, time to update. ⭐


Simple Directmedia Layer πŸ¦‹ β€” SDL 3.4.18 β€” SDLCALL(3), and that's the whole page, mwah πŸ’‹ go tag your callbacks, ily, bye!! πŸŽ€βœ¨πŸ’œ

πŸ“¦ where this page comes from