Function SDL_INIT_INTERFACE

pub unsafe fn SDL_INIT_INTERFACE<T>(iface: *mut T)
Available on crate feature dep_sdl3 only.
Expand description

A macro to initialize an SDL interface.

This macro will initialize an SDL interface structure and should be called before you fill out the fields with your implementation.

You can use it like this:

SDL_IOStreamInterface iface;

SDL_INIT_INTERFACE(&iface);

// Fill in the interface function pointers with your implementation
iface.seek = ...

stream = SDL_OpenIO(&iface, NULL);

If you are using designated initializers, you can use the size of the interface as the version, e.g.

SDL_IOStreamInterface iface = {
    .version = sizeof(iface),
    .seek = ...
};
stream = SDL_OpenIO(&iface, NULL);

§Thread safety

It is safe to call this macro from any thread.

§Availability

This macro is available since SDL 3.2.0.

§See also

  • [SDL_IOStreamInterface]
  • [SDL_StorageInterface]
  • [SDL_VirtualJoystickDesc]

§Safety (sdl3-sys)

  • iface must point to memory that is valid for writing the type T.
  • The type T must be a repr(C) struct.
  • The first field of the struct must be of type u32. It will be set to the size of the struct in bytes.
  • The rest of the struct will be initialized as all zero bytes.