libsdl-org / SDL

Simple Directmedia Layer
https://libsdl.org
zlib License
9.89k stars 1.83k forks source link

SDL_GetError() output is empty, when SDL_ReadU8 returns false #11395

Open Tsukulimer opened 4 days ago

Tsukulimer commented 4 days ago

SDL3 wiki says: call SDL_GetError() for more information.

#include <SDL3/SDL.h>
#include <stdio.h>

int main(int argc, char **argv)
{
    SDL_Init(SDL_INIT_VIDEO);

    SDL_IOStream *io = SDL_IOFromFile("empty_file", "rb");

    Uint8 c;

    if (SDL_ReadU8(io, &c) == false)
        printf("test: %s\n", SDL_GetError());
} 

test:

Should empty output be interpreted as end of stream?

Lzard commented 3 days ago

The documentation should mention using SDL_GetIOStatus to check whether EOF was reached or an error actually happened.