SDL_Swap32(3)
π SDL_Swap32 π
okay bestie, welcome to SDL_Swap32, straight outta the SDL3 FUNCTIONS lineup β¨ this one's short and sweet and honestly kind of iconic for it.
πΈ NAME πΈ
SDL_Swap32 β Byte-swap an unsigned 32-bit number. that's it. that's the whole job. she flips your bytes and she does NOT elaborate π
π SYNOPSIS π
#include <SDL3/SDL_endian.h>
SDL_FORCE_INLINE Uint32 SDL_Swap32(Uint32 x);
β¨ DESCRIPTION β¨
okay so listen. this function will always byte-swap the value, no cap β whether it's currently in the native byteorder of the system or not. like, it does not check. it does not care. it just swaps. periodt.
which is exactly why, in most cases, you should be using SDL_Swap32LE or SDL_Swap32BE instead. those two are the responsible ones who actually look before they leap π«Ά
π important lore alert: this is a forced-inline function in a header, NOT a public API function available in the SDL library. which is to say β the code is embedded in the calling program, and the linker and dynamic loader will not be able to find this function inside SDL itself. she lives in your binary now. no takebacks π
π§ FUNCTION PARAMETERS π§
xβ the value to byte-swap. hand her your lil 32-bit number and she'll hand it back flipped π
β RETURN VALUE β
Returns x, with its bytes in the opposite endian order. same number, new arrangement, main character energy π
π THREAD SAFETY π
It is safe to call this function from any thread. go wild, gorl, every thread can have a turn π
π¦ AVAILABILITY π¦
This function is available since SDL 3.2.0. if you're on anything older, sorry bestie, she hasn't been born yet π
okay that's the whole page, love that for us π mwah π
β Simple Directmedia Layer, SDL 3.4.18, and yes this was SDL_Swap32(3) the whole time. stream it, byte-swap responsibly, bye bestie π«Άβ¨
π¦ 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