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
- 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