sdlSetError function

int sdlSetError(
  1. String? fmt,
  2. Pointer<NativeType> arg1
)

Set the SDL error message for the current thread.

Calling this function will replace any previous error message that was set.

This function always returns -1, since SDL frequently uses -1 to signify an failing result, leading to this idiom:

if (error_code) {
return SDL_SetError("This operation has failed: %d", error_code);
}

\param fmt a printf()-style message format string \param ... additional parameters matching % tokens in the fmt string, if any \returns always -1.

\since This function is available since SDL 2.0.0.

\sa SDL_ClearError \sa SDL_GetError

extern DECLSPEC int SDLCALL SDL_SetError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(1)

Implementation

int sdlSetError(String? fmt, Pointer<NativeType> arg1) {
  final sdlSetErrorLookupFunction = libSdl2.lookupFunction<
      Int32 Function(Pointer<Utf8> fmt, Pointer<NativeType> arg1),
      int Function(
          Pointer<Utf8> fmt, Pointer<NativeType> arg1)>('SDL_SetError');
  final fmtPointer = fmt != null ? fmt.toNativeUtf8() : nullptr;
  final result = sdlSetErrorLookupFunction(fmtPointer, arg1);
  calloc.free(fmtPointer);
  return result;
}