SDL_Swap64BE(3)

πŸ’– SDL_Swap64BE πŸ’–

okay bestie, welcome to the SDL3 FUNCTIONS corner of the manual, where we're talking about SDL_Swap64BE(3) β€” the little macro that fixes your endianness problems before they even start. no cap.


✨ NAME ✨

SDL_Swap64BE β€” Swap a 64-bit value from bigendian to native byte order.

like, it takes your bigendian-flavored 64-bit number and hands it back in whatever byte order your machine actually speaks. endianness translation era πŸ¦‹


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_endian.h>

#define SDL_Swap64BE(x) SwapOnlyIfNecessary(x)

she's a macro, not a function. #define girlie through and through. πŸ’…


πŸŽ€ DESCRIPTION πŸŽ€

so here's the vibe: if this is running on a bigendian system, then x is returned unchanged. literally untouched. because if you're already bigendian, why would we do extra work? that would be giving unnecessary labor energy and we don't do that here. πŸ‘‘

and this is the part that's genuinely iconic: this macro never references x more than once, which avoids side effects. so if you pass something spicy into it, it's not getting evaluated twice behind your back. no sneaky double-evaluation, no surprises, no betrayal. 🫢


πŸ’œ MACRO PARAMETERS πŸ’œ

  • x β€” the value to swap, in bigendian byte order.

that's it. one parameter. she's low maintenance. 🌸


⭐ RETURN VALUE ⭐

Returns x in native byte order. that's the whole delivery. your value, but make it local. ✨


πŸ”₯ THREAD SAFETY πŸ”₯

It is safe to call this macro from any thread. any of them. all of them. thread girlies, you are so welcome here. πŸ’–


🌈 AVAILABILITY 🌈

This macro is available since SDL 3.2.0. so if you're on an older SDL, bestie, this is your sign to upgrade. πŸ™ˆ


πŸ‘‘ SEE ALSO πŸ‘‘

ngl, there's nothing else listed here, but if you're messing with byte order you probably already know what you're doing. iykyk. πŸ’…


⚠️ tiny reminder: this macro never touches x more than once, so please don't assume it'll behave like a multi-reference macro. it won't. and that's a good thing. πŸŽ€

okay that's the whole page, bestie, you ate it, you understood it, and now you're an endianness main character. periodt. πŸ’–βœ¨πŸŽ€πŸ¦‹πŸŒΈ

this lil page came to you courtesy of Simple Directmedia Layer, running the SDL 3.4.18 era of the docs β€” mwah, sending you and your 64-bit values so much love. πŸ«ΆπŸ’œπŸ“

πŸ“¦ where this page comes from