SDL_SCANF_VARARG_FUNC(3)
π SDL_SCANF_VARARG_FUNC β bestie edition
okay so this one lives in the SDL3 FUNCTIONS manual, and it's literally a macro that annotates a vararg function that operates like scanf. that's the whole vibe. π
β¨ NAME β¨
SDL_SCANF_VARARG_FUNC β a macro that annotates a vararg function that operates like scanf. no cap, that's the entire job description. π¦
πΈ SYNOPSIS πΈ
#include <SDL3/SDL_stdinc.h>
#define SDL_SCANF_VARARG_FUNC( fmtargnumber ) __attribute__ (( format( __scanf__, fmtargnumber, fmtargnumber+1 )))
π DESCRIPTION π
okay so picture this. say we wanted to annotate fscanf. it would look like this:
int fscanf(FILE *f, const char *fmt, ...) SDL_PRINTF_VARARG_FUNCV(2);
and what that's telling everybody is that the second parameter should be a scanf-style format string, followed by .... that's it. that's the assignment. π
then the compiler β or whatever other analysis tool is lurking in the group chat β can warn when this doesn't appear to be the case. like, "girl, that's not a format string." π
on compilers that don't have this annotation mechanism, this is defined to nothing. like, it just evaporates. poof. gone. defined to nothing. not a vibe but we move. π«Ά
and here's the part where you use it together: this can (and should) be used with SDL_SCANF_FORMAT_STRING as well β which between them will cover at least Visual Studio, GCC, and Clang. iconic trio honestly. π
π AVAILABILITY π
this macro is available since SDL 3.2.0. β¨
and that's the whole page, bestie. no notes. π
Simple Directmedia Layer β SDL 3.4.18 β SDL_SCANF_VARARG_FUNC(3). mwah, go forth and annotate your varargs, 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