SDL_PRIX32(3)

πŸ’– SDL_PRIX32 πŸ’–

okay bestie, so this is the SDL_PRIX32 page from the SDL3 FUNCTIONS corner of the SDL_PRIX32(3) manual, and honestly? it's a tiny little macro but it's iconic and you're gonna love her πŸ’…


✨ NAME ✨

SDL_PRIX32 β€” it's a printf-formatting string that lets you print a Uint32 value as upper-case hexadecimal. that's it. that's the whole job. queen of doing one thing and doing it flawlessly πŸ‘‘


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_stdinc.h>

#define SDL_PRIX32 "X"

like. look at her. one single "X". so small. so powerful. πŸ¦‹


πŸ’œ DESCRIPTION πŸ’œ

so the way that you use this is you stick it in your format string and let printf-style concatenation do its little magic. use it like this:

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

see how the % is hanging out right before it? that's the vibe. the % does the percent-y part, SDL_PRIX32 expands to "X", and the compiler smooshes the string literals together so the whole thing is just %X at runtime. no cap, it's giving string-literal-adjacency sorcery ✨

and why does this macro even exist instead of you just typing "X" yourself? because the correct format specifier for a Uint32 is not the same everywhere, and using the macro means you never have to think about it. you just get upper-case hex, correctly, forever. periodt. πŸ’…


πŸŽ€ AVAILABILITY πŸŽ€

this macro has been available since SDL 3.2.0. so if you're on anything older, sorry babe, she's not there yet 😭


and that's the whole page! short and sweet, just like a good macro should be πŸ“

cute lil sign-off: this was served up fresh from the Simple Directmedia Layer, rocking SDL 3.4.18, and yeah it's SDL_PRIX32(3) all the way down. go forth and print your hex, bestie 🫢✨

πŸ“¦ where this page comes from