SDL_SwapFloatLE(3)

πŸ’… SDL_SwapFloatLE πŸ’…

okay bestie, welcome to the SDL3 FUNCTIONS corner of the group chat 🌸 this one is called SDL_SwapFloatLE and it does exactly one adorable job: it swaps a floating point value from littleendian to native byte order. that's it. that's the whole personality. and honestly? iconic. ✨


🌈 SYNOPSIS 🌈

#include <SDL3/SDL_endian.h>

#define SDL_SwapFloatLE(x) SwapOnlyIfNecessary(x)

like. look at her. one macro, one job, no drama. πŸŽ€


πŸ’– DESCRIPTION πŸ’–

so here's the tea β˜• β€” if this is running on a littleendian system, then x gets returned unchanged. no swapping, no nothing, because babes it's already in the right order πŸ’…

and the best part: this macro never references x more than once, which means you avoid side effects. no sneaky double-evaluation jumpscare. it's giving ✨ responsible ✨. obsessed. 🫢


πŸŽ€ MACRO PARAMETERS πŸŽ€

  • x β€” the value to swap, in littleendian byte order. that's the one, the only, the main character of this whole operation πŸ‘‘

⭐ RETURN VALUE ⭐

Returns x in native byte order. so like, if you were on a bigendian system, you'd get the swapped version back; otherwise you get your baby back exactly how you left her πŸ¦‹


🧚 THREAD SAFETY 🧚

It is safe to call this macro from any thread. no locks, no stress, no "wait who's touching that" energy. go off, multithreaded queen πŸ’œ


πŸ‘‘ AVAILABILITY πŸ‘‘

This macro is available since SDL 3.2.0. so if you're on anything older... bestie. upgrade. it's not a vibe. πŸ™ˆ


⚠️ tiny reminder: x is a floating point value, and it's coming in as littleendian. keep that straight and you're golden ✨

and that's the whole page, periodt πŸ’…πŸ’– written for Simple Directmedia Layer, and this lil manual is living in SDL 3.4.18 β€” so go forth, swap those floats, and slay πŸŽ€πŸ¦‹πŸŒΈ byeeee 🫢✨

πŸ“¦ where this page comes from