From 066f49da1ada964a1e7a19dfab60d4d06dfcf398 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Sun, 26 May 2024 22:53:06 -0400 Subject: [PATCH] main: Add some macros for main callback return codes. Fixes #9883. --- include/SDL3/SDL_main.h | 45 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/include/SDL3/SDL_main.h b/include/SDL3/SDL_main.h index 0b003e6e1f..08cf64efdf 100644 --- a/include/SDL3/SDL_main.h +++ b/include/SDL3/SDL_main.h @@ -188,7 +188,7 @@ typedef int (SDLCALL *SDL_AppIterate_func)(void *appstate); typedef int (SDLCALL *SDL_AppEvent_func)(void *appstate, const SDL_Event *event); typedef void (SDLCALL *SDL_AppQuit_func)(void *appstate); -/** +/* * You can (optionally!) define SDL_MAIN_USE_CALLBACKS before including * SDL_main.h, and then your application will _not_ have a standard * "main" entry point. Instead, it will operate as a collection of @@ -214,6 +214,49 @@ typedef void (SDLCALL *SDL_AppQuit_func)(void *appstate); */ #ifdef SDL_MAIN_USE_CALLBACKS +/** + * Value that requests that the app continue from the main callbacks. + * + * If SDL_AppInit, SDL_AppEvent, or SDL_AppIterate returns this value, + * the program will continue to run. This is the normal return value case. + * + * This is always 0; using this macro may be clearer, but is not required. + * + * \since This macro is available since SDL 3.0.0. + */ +#define SDL_MAIN_CALLBACK_CONTINUE 0 + +/** + * Value that requests termination with error from the main callbacks. + * + * If SDL_AppInit, SDL_AppEvent, or SDL_AppIterate returns this value, + * the program will terminate and report failure to the operating system. + * + * What that failure looks like is platform-dependent. On Unix, for example, + * the process error code will be non-zero. + * + * This is always -1; using this macro may be clearer, but is not required. + * + * \since This macro is available since SDL 3.0.0. + */ +#define SDL_MAIN_CALLBACK_EXIT_FAILURE -1 + +/** + * Value that requests termination with success from the main callbacks. + * + * If SDL_AppInit, SDL_AppEvent, or SDL_AppIterate returns this value, + * the program will terminate and report success to the operating system. + * + * What that success looks like is platform-dependent. On Unix, for example, + * the process error code will be zero. + * + * This is always 1; using this macro may be clearer, but is not required. + * + * \since This macro is available since SDL 3.0.0. + */ +#define SDL_MAIN_CALLBACK_EXIT_SUCCESS 1 + + /** * App-implemented initial entry point for SDL_MAIN_USE_CALLBACKS apps. *