SDL_OUT_CAP(3)
π SDL_OUT_CAP π
okay so bestie, welcome to SDL_OUT_CAP β it's a macro from the SDL3 functions crew, and honestly? it's giving "quietly doing the most." it's the lil annotation that tells everyone your output buffer is big enough. no cap. (well, actually, cap. that's the whole point. π)
β¨ NAME β¨
SDL_OUT_CAP β a macro that annotates function params with output buffer size. that's it, that's the job. π
πΈ SYNOPSIS πΈ
#include <SDL3/SDL_stdinc.h>
#define SDL_OUT_CAP(x) _Out_cap_(x)
π¦ DESCRIPTION π¦
so like, imagine we wanted to annotate wcsncpy, right? it would look a lil something like this:
char *wcscpy(SDL_OUT_CAP(bufsize) wchar_t *dst, const wchar_t *src, size_t bufsize);
this is noting that dst should have a capacity of bufsize wchar_t in size, and that it's only written to by the function. then the compiler or other analysis tools can be the friend who tells you the truth and warn when that doesn't appear to be the case. π so real of them.
β οΈ important, bestie: this operates on counts of objects, not bytes. if you're counting bytes instead, use SDL_OUT_BYTECAP for bytes. don't mix them up, i'm begging. π
and for the compilers that simply do not have this annotation mechanism? iconic behaviour β on those, this is defined to nothing. it just vanishes. poof. no drama. π
π AVAILABILITY π
this macro is available since SDL 3.2.0. periodt. π
Simple Directmedia Layer β SDL 3.4.18 β SDL_OUT_CAP(3)
and that's the whole page, bestie π«Ά go annotate some buffers, stay hydrated, mwah πβ¨
π¦ 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