Man page - sdl_nodiscard(3)
Packages contains this manual
Manual
SDL_NODISCARD
NAMEHEADER FILE
SYNOPSIS
DESCRIPTION
AVAILABILITY
NAME
SDL_NODISCARD - A macro to tag a functionâs return value as critical.
HEADER FILE
Defined in SDL3/SDL_begin_code.h
SYNOPSIS
#include "SDL3/SDL.h"
#define SDL_NODISCARD [[nodiscard]]
DESCRIPTION
This is a hint to the compiler that a functionâs return value should not be ignored.
If an NODISCARD functionâs return value is thrown away (the function is called as if it returns void ), the compiler will issue a warning.
While itâs generally good practice to check return values for errors, often times legitimate programs do not for good reasons. Be careful about what functions are tagged as NODISCARD. It operates best when used on a function thatâs 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.
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.
On compilers without nodiscard support, this is defined to nothing.
AVAILABILITY
This macro is available since SDL 3.2.0.