SDL_ReadS32BE(3)

πŸ’– SDL_ReadS32BE πŸ’–

okay bestie, so this is a page from the SDL3 FUNCTIONS manual, and today's main character is SDL_ReadS32BE ✨


✨ NAME ✨

SDL_ReadS32BE β€” use this function to read 32 bits of big-endian data from an SDL_IOStream and return it in native format 🫢


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_iostream.h>

bool SDL_ReadS32BE(SDL_IOStream *src, Sint32 *value);

πŸ’… DESCRIPTION πŸ’…

So here's the tea: SDL byteswaps the data only if necessary, which means the data you get back will be in the native byte order. No cap. It's giving considerate πŸ’–

Now for the sad part 😭 β€” this function will return false when the data stream is completely read, and SDL_GetIOStatus() will return SDL_IO_STATUS_EOF. So like, that's not a bad false, that's just the end, okay?

But β€” and this is the important bit β€” if false is returned and the stream is not at EOF, then SDL_GetIOStatus() will return a different error value, and SDL_GetError() will offer you a human-readable message. So check your status, babe, don't just assume πŸ’€


πŸŽ€ FUNCTION PARAMETERS πŸŽ€

  • src β€” the stream from which to read data πŸ¦‹
  • value β€” a pointer filled in with the data read ✨

πŸ‘‘ RETURN VALUE πŸ‘‘

Returns true on successful read, or false on failure. If it fails, call SDL_GetError() for more info β€” she'll tell you what went wrong 🌈


πŸ’€ THREAD SAFETY πŸ’€

Do not use the same SDL_IOStream from two threads at once. Just don't. It's not that kind of stream, and you will regret it πŸ™ˆ


⭐ AVAILABILITY ⭐

This function is available since SDL 3.2.0 πŸŽ‰


Simple Directmedia Layer made this, it's SDL 3.4.18, and that's the whole page, bestie β€” go read some big-endian bytes responsibly πŸ’…πŸ«ΆπŸ’–

πŸ“¦ where this page comes from