Removed guard around the enabled assertions support code

Otherwise, SDL_assert_always() wouldn't work.

Fixes https://github.com/libsdl-org/SDL/issues/7433
This commit is contained in:
Ozkan Sezer 2023-03-09 20:51:50 +03:00
parent 54ca4d3879
commit 69875ad80f
1 changed files with 3 additions and 9 deletions

View File

@ -125,12 +125,10 @@ typedef struct SDL_AssertData
const struct SDL_AssertData *next; const struct SDL_AssertData *next;
} SDL_AssertData; } SDL_AssertData;
#if (SDL_ASSERT_LEVEL > 0)
/* Never call this directly. Use the SDL_assert* macros. */ /* Never call this directly. Use the SDL_assert* macros. */
extern DECLSPEC SDL_AssertState SDLCALL SDL_ReportAssertion(SDL_AssertData *, extern DECLSPEC SDL_AssertState SDLCALL SDL_ReportAssertion(SDL_AssertData *,
const char *, const char *,
const char *, int) const char *, int)
#if defined(__clang__) #if defined(__clang__)
#if __has_feature(attribute_analyzer_noreturn) #if __has_feature(attribute_analyzer_noreturn)
/* this tells Clang's static analysis that we're a custom assert function, /* this tells Clang's static analysis that we're a custom assert function,
@ -151,9 +149,7 @@ extern DECLSPEC SDL_AssertState SDLCALL SDL_ReportAssertion(SDL_AssertData *,
#define SDL_enabled_assert(condition) \ #define SDL_enabled_assert(condition) \
do { \ do { \
while ( !(condition) ) { \ while ( !(condition) ) { \
static struct SDL_AssertData sdl_assert_data = { \ static struct SDL_AssertData sdl_assert_data = { 0, 0, #condition, 0, 0, 0, 0 }; \
0, 0, #condition, 0, 0, 0, 0 \
}; \
const SDL_AssertState sdl_assert_state = SDL_ReportAssertion(&sdl_assert_data, SDL_FUNCTION, SDL_FILE, SDL_LINE); \ const SDL_AssertState sdl_assert_state = SDL_ReportAssertion(&sdl_assert_data, SDL_FUNCTION, SDL_FILE, SDL_LINE); \
if (sdl_assert_state == SDL_ASSERTION_RETRY) { \ if (sdl_assert_state == SDL_ASSERTION_RETRY) { \
continue; /* go again. */ \ continue; /* go again. */ \
@ -164,8 +160,6 @@ extern DECLSPEC SDL_AssertState SDLCALL SDL_ReportAssertion(SDL_AssertData *,
} \ } \
} while (SDL_NULL_WHILE_LOOP_CONDITION) } while (SDL_NULL_WHILE_LOOP_CONDITION)
#endif /* enabled assertions support code */
/* Enable various levels of assertions. */ /* Enable various levels of assertions. */
#if SDL_ASSERT_LEVEL == 0 /* assertions disabled */ #if SDL_ASSERT_LEVEL == 0 /* assertions disabled */
# define SDL_assert(condition) SDL_disabled_assert(condition) # define SDL_assert(condition) SDL_disabled_assert(condition)