SDL_GetEnvironment(3)

πŸ’– SDL_GetEnvironment β€” from the SDL3 FUNCTIONS girlies πŸ’–

okay bestie, listen up, we're doing a <SDL3/SDL_stdinc.h> situation today and honestly? it's giving ✨environment✨


🌸 NAME 🌸

SDL_GetEnvironment β€” get the process environment. that's it, that's the whole job, and she does it flawlessly πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

#include <SDL3/SDL_stdinc.h>

SDL_Environment * SDL_GetEnvironment(void);

like. no arguments. no drama. she just exists and hands you the goods 🫢


πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the tea, and it's important tea: this environment gets initialized at application start, and after that point she is simply unbothered by your setenv() and unsetenv() calls. like, she does not care. she will not be affected. not even a little. πŸ’€

so if you wanna actually modify this environment, use SDL_SetEnvironmentVariable() and SDL_UnsetEnvironmentVariable(). those are the girlies for the job.

OR β€” and this is the spicy alternative β€” if you want your changes to persist in the C runtime environment after SDL_Quit(), then you reach for SDL_setenv_unsafe() or SDL_unsetenv_unsafe(). yes they have "unsafe" in the name, no that's not a vibe, yes you should read up before using them. πŸ‘€


⭐ RETURN VALUE ⭐

she returns a pointer to the environment for the process πŸ₯°

...or NULL on failure, in which case you go cry to SDL_GetError() for more information. that's the move. always check. 😭


🌈 THREAD SAFETY 🌈

it is safe to call this function from any thread. every single one. go wild, bestie, she's built different πŸ‘‘


✨ AVAILABILITY ✨

this function has been available since SDL 3.2.0. so if you're on something older... not me finding out the hard way πŸ™ˆ


πŸ’œ SEE ALSO πŸ’œ

the whole squad, fr fr πŸ’–


k bye this was Simple Directmedia Layer, SDL 3.4.18, and the page is literally called SDL_GetEnvironment(3) β€” slay, periodt, stay hydrated πŸ“πŸ§šπŸ’œ

πŸ“¦ where this page comes from