SDL_ReadU8(3)

✨ SDL_ReadU8 β€” the SDL3 FUNCTIONS girlies know πŸ’…

okay bestie, pull up a chair 🫢 this one is literally the smallest little guy in the whole SDL3 lineup: SDL_ReadU8, and yes she eats. no cap.


🌸 NAME 🌸

SDL_ReadU8 β€” use this function to read a byte from an SDL_IOStream. one (1) single byte. that's the whole job. iconic, honestly. πŸŽ€


✨ SYNOPSIS ✨

#include <SDL3/SDL_iostream.h>

bool SDL_ReadU8(SDL_IOStream *src, Uint8 *value);

πŸ’– DESCRIPTION πŸ’–

so here's the tea β˜• β€” this function will return false when the data stream is completely read, and SDL_GetIOStatus() will return SDL_IO_STATUS_EOF. like, that's the signal, bestie, that's how you know it's done. πŸ¦‹

BUT. and this is the important part πŸ‘‘ β€” if false comes back and the stream is not at EOF, then SDL_GetIOStatus() will return a different error value instead, and SDL_GetError() will offer you a human-readable message. so like, false on its own is not the whole story, you gotta check the status to know which kind of false you got. vibe check your return values, always. πŸ’€


πŸŽ€ FUNCTION PARAMETERS πŸŽ€

  • src β€” the SDL_IOStream to read from. this is the source, the origin story, the main character. 🌈
  • value β€” a pointer filled in with the data read. she's an out-param, so you pass the address and she gets written into. literally handing her a little cup to fill. πŸ“

🌟 RETURN VALUE 🌟

Returns true on success, or false on failure or EOF. and if you're sitting there like "okay but which one 😭", call SDL_GetError() for more information. fr fr, always read the error, it's giving free lore. πŸ’œ


🧚 THREAD SAFETY 🧚

Do not use the same SDL_IOStream from two threads at once. πŸ›‘

that's not a suggestion, that's the rule. one stream, one thread, no sharing, no drama. we do not pass the stream around the group chat. πŸ™ˆ


⭐ AVAILABILITY ⭐

This function is available since SDL 3.2.0. so if you're on something older, sorry babe, she's not there yet. πŸ’…


and that's the whole page, bestie 🫢 go forth and read your bytes one at a time, exactly like the universe intended. ✨

with love from Simple Directmedia Layer, SDL 3.4.18 β€” mwah πŸ’‹ see u in the next manpage πŸŽ€πŸ¦‹πŸ’–

πŸ“¦ where this page comes from