SDL_Swap32LE(3)

πŸ’… NAME πŸ’…

SDL_Swap32LE β€” bestie, this one swaps a 32-bit value from littleendian over to native byte order. that's it, that's the whole job πŸ¦‹


✨ SYNOPSIS ✨

#include <SDL3/SDL_endian.h>

#define SDL_Swap32LE(x) SwapOnlyIfNecessary(x)

🌸 DESCRIPTION 🌸

okay so picture this: if this is running on a littleendian system, then x just gets returned unchanged. no drama, no swap, nothing. it simply comes back to you exactly how you sent it πŸ’–

and here's the part that's genuinely iconic: this macro never references x more than once, which means it avoids side effects. so you can pass it something spicy and it won't double-dip on you. no cap πŸ”₯


πŸŽ€ MACRO PARAMETERS πŸŽ€

  • x β€” the value to swap, in littleendian byte order. hand it over and let the macro cook πŸ“

πŸ‘‘ RETURN VALUE πŸ‘‘

Returns x in native byte order. that's the glow-up πŸ’…


🧚 THREAD SAFETY 🧚

It is safe to call this macro from any thread. every thread can get a turn, we don't gatekeep 🌈


⭐ AVAILABILITY ⭐

This macro is available since SDL 3.2.0. so if you're on anything older… yeah, you're not invited to this one 😭


lowkey obsessed with a macro that minds its own business and only touches your variable one time. main character energy fr fr 🫢

k bye bestie, this page came to you courtesy of Simple Directmedia Layer β€” the one and only SDL 3.4.18 era πŸ’–βœ¨πŸŽ€ go swap something, iykyk πŸ¦‹

πŸ“¦ where this page comes from