SDL_NODISCARD(3)
π SDL_NODISCARD(3) β the SDL3 FUNCTIONS girlies' edition
okay so bestie, welcome to the SDL3 FUNCTIONS manual, and today's main character is SDL_NODISCARD β¨
πΈ NAME πΈ
SDL_NODISCARD β a macro that tags a function's return value as critical. like, do NOT just toss it, okay?? π«Ά
β¨ SYNOPSIS β¨
#include <SDL3/SDL_begin_code.h>
#define SDL_NODISCARD [[nodiscard]]
π¦ DESCRIPTION π¦
So this macro is literally a lil hint you drop for the compiler, telling it that a function's return value should not be ignored. it's giving "hey bestie, look at this" energy. π
If an NODISCARD function's return value gets thrown away β like, the function is called as if it returns void β the compiler will issue a warning. not me getting called out by the compiler π
Now here's the tea: while it's generally good practice to check return values for errors, often times legitimate programs do not, for good reasons. so be careful about which functions you tag as NODISCARD, fr fr. it operates best when used on a function whose failure is surprising and catastrophic; a good example would be a program that checks the return values of all its file write function calls but not the call to close the file, which it assumes incorrectly never fails. like girl. that assumption is not it. π
Function callers that want to throw away a NODISCARD return value can call the function with a (void) cast, which informs the compiler the act is intentional. slay, consent given, no warnings today. β
On compilers without nodiscard support, this is defined to nothing. so it just... vibes. no cap. π
π AVAILABILITY π
This macro has been available since SDL 3.2.0. iconic behavior, honestly. β
k that's the whole page bestie, go check your return values, mwah π
this has been your girl from Simple Directmedia Layer, reporting live from SDL 3.4.18 β SDL_NODISCARD(3), out. ππ¦π
π¦ where this page comes from
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms