SDL_PRILLx(3)

πŸ’… SDL_PRILLx β€” bestie edition

okay so you're in the SDL3 FUNCTIONS manual, section 3, and today's main character is SDL_PRILLx. πŸŽ€


✨ NAME ✨

SDL_PRILLx β€” it's a printf-formatting string, and it's specifically for printing an unsigned long long value as lower-case hexadecimal. that's it. that's the whole job. she's niche but she's iconic. πŸ‘‘


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_stdinc.h>

#define SDL_PRILLx SDL_PRILL_PREFIX "x"

like, literally that's the whole definition. no cap. πŸ’–


πŸ¦‹ DESCRIPTION πŸ¦‹

so the vibe here is: you know how printf and friends need those little <inttypes.h> macros so your format string matches your actual integer type, and if you get it wrong everything explodes into undefined behaviour? yeah. this is SDL's version of that, and she ate. πŸ”₯

use it like this:

SDL_Log("There are %" SDL_PRILLx " bottles of beer on the wall.", bottles);

see how the macro gets string-concatenated right into the middle of the format string? that's the move. the % lives in your string, the macro supplies the conversion specifier, and they snap together like they were always meant to be. πŸ’…

ngl, string literal concatenation like this is the whole reason these PRI* macros exist as macros and not just as variables. iykyk. 🧚


⭐ AVAILABILITY ⭐

this macro has been around since SDL 3.2.0. so if you're on anything older, bestie, it's not there and you're gonna have a bad time. πŸ™ˆ


πŸ’€ SEE ALSO πŸ’€

okay technically this section isn't in the original but the energy is: go look at the other SDL_PRI* siblings if you need a different integer type or a different base, because she has a whole family and they're all serving. 🫢


fr fr, don't just guess the format specifier for your type. use the macro. future you, staring at a segfault at 2am, will thank you. 😭

sign-off time, besties πŸ“ this page comes to you from Simple Directmedia Layer, it's for SDL 3.4.18, and the page itself is SDL_PRILLx(3). mwah. go print some hex. πŸ’œβœ¨

πŸ“¦ where this page comes from