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