Mercurial > sdl-ios-xcode
comparison include/SDL_assert.h @ 3649:1e74d7984d0b
The config sets the default assertion level so people can override it for their own use in application code.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Wed, 13 Jan 2010 07:25:28 +0000 |
parents | c5925cd41955 |
children | 91460fdfe83a |
comparison
equal
deleted
inserted
replaced
3648:a9d830c05998 | 3649:1e74d7984d0b |
---|---|
19 Sam Lantinga | 19 Sam Lantinga |
20 slouken@libsdl.org | 20 slouken@libsdl.org |
21 */ | 21 */ |
22 #include "SDL_config.h" | 22 #include "SDL_config.h" |
23 | 23 |
24 /* This is an assert macro for SDL's internal use. Not for the public API! */ | |
25 | |
26 #ifndef _SDL_assert_h | 24 #ifndef _SDL_assert_h |
27 #define _SDL_assert_h | 25 #define _SDL_assert_h |
28 | 26 |
29 #ifndef SDL_ASSERT_LEVEL | 27 #ifndef SDL_ASSERT_LEVEL |
30 #error SDL_ASSERT_LEVEL is not defined. Please fix your SDL_config.h. | 28 #define SDL_ASSERT_LEVEL SDL_DEFAULT_ASSERT_LEVEL |
31 #endif | 29 #endif |
32 | 30 |
33 /* | 31 /* |
34 sizeof (x) makes the compiler still parse the expression even without | 32 sizeof (x) makes the compiler still parse the expression even without |
35 assertions enabled, so the code is always checked at compile time, but | 33 assertions enabled, so the code is always checked at compile time, but |
105 SDL_ReportAssertion(), in SDL_assert.c. | 103 SDL_ReportAssertion(), in SDL_assert.c. |
106 */ | 104 */ |
107 #define SDL_enabled_assert(condition) \ | 105 #define SDL_enabled_assert(condition) \ |
108 do { \ | 106 do { \ |
109 while ( !(condition) ) { \ | 107 while ( !(condition) ) { \ |
110 static struct SDL_assert_data assert_data = { \ | 108 static struct SDL_assert_data assert_data = { \ |
111 0, 0, #condition, __FILE__, 0, 0, 0 \ | 109 0, 0, #condition, __FILE__, 0, 0, 0 \ |
112 }; \ | 110 }; \ |
113 const SDL_assert_state state = SDL_ReportAssertion(&assert_data, \ | 111 const SDL_assert_state state = SDL_ReportAssertion(&assert_data, \ |
114 SDL_FUNCTION, \ | 112 SDL_FUNCTION, \ |
115 __LINE__); \ | 113 __LINE__); \ |
116 if (state == SDL_ASSERTION_RETRY) { \ | 114 if (state == SDL_ASSERTION_RETRY) { \ |
117 continue; /* go again. */ \ | 115 continue; /* go again. */ \ |
118 } else if (state == SDL_ASSERTION_BREAK) { \ | 116 } else if (state == SDL_ASSERTION_BREAK) { \ |
119 SDL_TriggerBreakpoint(); \ | 117 SDL_TriggerBreakpoint(); \ |
120 } \ | 118 } \ |
146 #endif | 144 #endif |
147 | 145 |
148 #endif /* _SDL_assert_h */ | 146 #endif /* _SDL_assert_h */ |
149 | 147 |
150 /* vi: set ts=4 sw=4 expandtab: */ | 148 /* vi: set ts=4 sw=4 expandtab: */ |
151 |