SDL_Swap16LE(3)
π SDL_Swap16LE π
okay bestie, welcome to the SDL3 FUNCTIONS corner of the manual, where today's main character is SDL_Swap16LE β the little macro that flips a 16-bit value from littleendian into whatever byte order your machine actually speaks. she's small, she's precise, she's iconic. let's get into it π
β¨ NAME β¨
SDL_Swap16LE β swap a 16-bit value from littleendian to native byte order. that's it, that's the job, and she does it flawlessly π
πΈ SYNOPSIS πΈ
#include <SDL3/SDL_endian.h>
#define SDL_Swap16LE(x) SwapOnlyIfNecessary(x)
so yeah, it's a macro, not a function. no cap. she expands into SwapOnlyIfNecessary(x) and lets the preprocessor handle the rest π¦
π DESCRIPTION π
okay so here's the vibe: if this is running on a littleendian system, then x is returned unchanged. like, no swap needed, nothing to do, she just hands it right back to you. periodt β¨
and here's the part that's lowkey genius β this macro never references x more than once, which avoids side effects. so if you were ever worried about your expression getting evaluated twice behind your backβ¦ not today, bestie π
π MACRO PARAMETERS π
xβ the value to swap, in littleendian byte order. give her the 16-bit cutie in LE, she'll give you back native π
π«Ά RETURN VALUE π«Ά
Returns x in native byte order. simple, clean, no drama π
π₯ THREAD SAFETY π₯
It is safe to call this macro from any thread. yes bestie, any thread β she's got no shared state, no secrets, no β¨complicatedβ¨ past. go wild, she can handle it π
β AVAILABILITY β
This macro is available since SDL 3.2.0. so if you're on something olderβ¦ upgrade, babe π
π§ tiny reminder: everything above is literally exactly what she does. don't get creative with the byte order and then blame the macro. iykyk π
and that's the whole page, bestie! this little love letter came to you from Simple Directmedia Layer, rocking version SDL 3.4.18, and honestly? she ate. go forth and swap responsibly π πβ¨
π¦ where this page comes from
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms