All SDL functions that set error messages have a way to signal that an
error has occured (e.g. returning a NULL pointer or non-zero int).
So you should not be calling SDL_GetError() just to see if an error has
occurred. Call it to get more info for an error that you’ve already
detected.
If you really do want to use SDL_GetError() to detect errors, you must call
SDL_ClearError() to reset the error status before you make the calls that
might generate the errors.