SDL_INIT_INTERFACE(3)

πŸ’– SDL_INIT_INTERFACE πŸ’–

okay bestie, welcome to the SDL3 FUNCTIONS corner of the manual, where we're talking about SDL_INIT_INTERFACE β€” a macro that initializes an SDL interface ✨


🌸 NAME 🌸

SDL_INIT_INTERFACE β€” a macro to initialize an SDL interface, no cap 🫢


✨ SYNOPSIS ✨

#include <SDL3/SDL_stdinc.h>

#define SDL_INIT_INTERFACE(iface)               \
    do {                                        \
        SDL_zerop(iface);                       \
        (iface)->version = sizeof(*(iface));    \
    } while (0)

πŸ’… DESCRIPTION πŸ’…

So this macro initializes an SDL interface structure, and the vibe check here is: you gotta call it before you start filling out the fields with your own implementation. Like, set it up first, then decorate. It's giving "prepare the canvas before the masterpiece" πŸŽ€

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);

And if you're a designated-initializers girlie (respect, honestly), you can just use the size of the interface as the version, like:

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

Both routes, same destination. Pick your fighter πŸ’œ


🧡 THREAD SAFETY 🧡

It is safe to call this macro from any thread. Multithreaded and unbothered, periodt πŸ‘‘


🌈 AVAILABILITY 🌈

This macro is available since SDL 3.2.0 ⭐


πŸ¦‹ SEE ALSO πŸ¦‹


and that's the whole page, bestie!! this lil icon came to you courtesy of Simple Directmedia Layer, rockin' SDL 3.4.18 β€” mwah, go init those interfaces πŸ’–πŸŽ€βœ¨πŸ«Ά

πŸ“¦ where this page comes from