SDL_FunctionPointer(3type)

✨ SDL_FunctionPointer(3type) ✨

okay so bestie, pull up a chair, because we're talking about SDL_FunctionPointer(3type) β€” a lil datatype from the SDL3 DATATYPES section of the manual and honestly? she's iconic for a reason. πŸ’…


🌸 NAME 🌸

SDL_FunctionPointer β€” a generic function pointer. that's it. that's the whole vibe. 🫢


πŸŽ€ SYNOPSIS πŸŽ€

#include <SDL3/SDL_stdinc.h>

typedef void (*SDL_FunctionPointer)(void);

look at her. one line. no drama. no cap. ✨


πŸ’– DESCRIPTION πŸ’–

so like, in theory, when you want a generic function pointer, you should be using this instead of void *. why? because some platforms could treat code addresses differently than data addresses. πŸ’€ like, the address of a function and the address of your data are not necessarily the same kind of beast on every system out there.

now, in current times no popular platforms make this distinction β€” so if you've been raw-dogging void * for function pointers this whole time, nobody's gonna come for you. but it is more correct and more portable to use the correct type for a generic pointer. main character behavior, honestly. πŸ‘‘

so like... use the right type. it's giving "I read the docs" energy and we love that for you. 🌈

if for some reason you need to force this typedef to be an actual void * β€” maybe to work around a compiler, or because of some existing code that refuses to cooperate β€” you can define SDL_FUNCTION_POINTER_IS_VOID_POINTER before including any SDL headers. not before. not after. before. okay bestie? before. πŸ™ˆ

⭐ AVAILABILITY ⭐

this datatype is available since SDL 3.2.0. so if you're on something older, she's simply not there yet, and you're gonna have to cope. 😭


and that's the whole page, bestie!! written by the lovely folks at Simple Directmedia Layer, sitting pretty at version SDL 3.4.18 β€” thanks for coming to my TED talk, go use the correct pointer type, mwah πŸ’‹ πŸ¦‹ 🌸

πŸ“¦ where this page comes from