SDL_PRINTF_VARARG_FUNC(3)

πŸ’– SDL_PRINTF_VARARG_FUNC πŸ’–

okay bestie, welcome to the SDL3 FUNCTIONS corner of the manual, this one lives in SDL_PRINTF_VARARG_FUNC and it's literally just a little macro that tells the compiler "hey, this vararg function does the printf thing" 🫢


✨ NAME ✨

SDL_PRINTF_VARARG_FUNC β€” a macro that annotates a vararg function that operates like printf. no cap, that's the whole job πŸŽ€


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_stdinc.h>

#define SDL_PRINTF_VARARG_FUNC( fmtargnumber ) __attribute__ (( format( __printf__, fmtargnumber, fmtargnumber+1 )))

πŸ¦‹ DESCRIPTION πŸ¦‹

so the vibe is: if we were to annotate fprintf, it would look like this πŸ‘‡

int fprintf(FILE *f, const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2);

what this notes is that the second parameter should be a printf-style format string, followed by .... and then the compiler β€” or other analysis tools β€” can warn when this doesn't appear to be the case. it's giving built-in proofreader energy, honestly πŸ‘‘

on compilers without this annotation mechanism, this is defined to nothing. yeah. it just quietly becomes nothing. it's fine. it's fine 😭

this can (and should) be used with SDL_PRINTF_FORMAT_STRING as well β€” between them, they will cover at least Visual Studio, GCC, and Clang. so like, use both, bestie, they're a matched set πŸ’…βœ¨


⭐ AVAILABILITY ⭐

this macro is available since SDL 3.2.0 πŸ“


and that's a wrap on this lil macro, you ate, go forth and annotate your varargs 🌈

Simple Directmedia Layer Β· SDL 3.4.18 Β· SDL_PRINTF_VARARG_FUNC(3) β€” mwah, xoxo, see you in the next manpage πŸ’œπŸ§š

πŸ“¦ where this page comes from