SDL_OUT_Z_CAP(3)
β¨ SDL_OUT_Z_CAP β¨
okay so bestie, welcome to the SDL3 FUNCTIONS corner of the manual π this one's a lil macro from SDL3 and it's honestly giving "quiet luxury" β tiny, does one job, slays at it.
πΈ NAME πΈ
SDL_OUT_Z_CAP β a macro that annotates your function params with the output string buffer size π like it's literally just a lil note to the compiler saying "hey, this buffer? here's how big it is".
π¦ SYNOPSIS π¦
#include <SDL3/SDL_stdinc.h>
#define SDL_OUT_Z_CAP(x) _Out_z_cap_(x)
π DESCRIPTION π
So picture this: you're annotating snprintf, right? It would look like this:
int snprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, const char *fmt, ...);
And what that's telling everyone is that text is a null-terminated C string π, that it should be maxlen bytes in size, and that it's only written to by the function β nobody's reading from it, no cap.
The way this pays off? The compiler or other analysis tools can warn you when that doesn't appear to be the case π which is iconic behaviour honestly.
and if you're on a compiler that doesn't have this annotation mechanism? it's just defined to nothing. no drama, no warnings, just vibes π
β AVAILABILITY β
This macro is available since SDL 3.2.0 π«Ά
mwah π that's the whole page, you ate it. this was brought to you by Simple Directmedia Layer, sitting pretty at version SDL 3.4.18 β go forth and annotate, bestie, ily πβ¨π¦
π¦ 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