Container structure for assert support.
More...
|
typedef int(* | callback_t) (void *pThis, const char *pCondition, const char *pFilename, uint32_t uLineNumber) |
| Redirect an assert to the application's assert function.
|
|
|
static int | default_assert (void *pThis, const char *pCondition, const char *pFilename, uint32_t uLineNumber) noexcept |
| Default assert function.
|
|
|
callback_t | m_pCallback |
| Function pointer to the redirected do_assert function.
|
|
void * | m_pThis |
| "this" pointer passed to the m_pCallback function
|
|
Container structure for assert support.
This global assert structure is used for supporting the ability to redirect an do_assert(const char , const char, uint32_t) call.
- See also
- do_assert(const char*, const char*, uint32_t), or BURGER_ASSERT
◆ callback_t
typedef int( * Burger::assert_t::callback_t) (void *pThis, const char *pCondition, const char *pFilename, uint32_t uLineNumber) |
Redirect an assert to the application's assert function.
When an assert is fired from the use of the macro BURGER_ASSERT this function is called which redirects to the currently logged assert function.
- Parameters
-
pThis | Pointer to the application supplied data pointer |
pCondition | String of the test condition that fired off the assert |
pFilename | The value of the __FILE__ macro at the location of the BURGER_ASSERT macro |
uLineNumber | The value of the __LINE__ macro at the location of the BURGER_ASSERT macro |
- Returns
- FALSE. Only return a non-false value if a very special case requires it because it may cause unexpected behavior from the use of the BURGER_ASSERT macro
◆ default_assert()
int BURGER_API Burger::assert_t::default_assert |
( |
void * | pThis, |
|
|
const char * | pCondition, |
|
|
const char * | pFilename, |
|
|
uint32_t | uLineNumber ) |
|
staticnoexcept |
Default assert function.
Prints the message "Assertion from \"%%s\\" in file %s at line
%u.\n", pCondition, pFilename, uLineNumber using Debug::Message(), and then calls invoke_debugger(). If execution continues, it will call Debug::Fatal() with the same message and exit the application.
- Note
- This function normally does not return and calls Debug::Fatal(). If the function returns, usually via manual user input in a debugger, it will return a conditional override which is 0 to match the condition that triggered the assert.
- Parameters
-
pThis | Ignored |
pCondition | Message to print do denote the cause of the assertion |
pFilename | Pointer to a "C" string of the source file name that triggered the assert |
uLineNumber | Line number in the source file that triggered the assert |
- Returns
- 0 (However, this function should never return)
- See also
- Debug::Message(), Debug::Fatal(), and do_assert(
const char*, const char*, uint32_t)
◆ set_callback()
Overrides the default do_assert function.
The normal behavior for do_assert(const char*, const char*, uint32_t) is to call printf() with the failure condition and then call Debug::Fatal(). This behavior can be overridden by passing a new function pointer via this call.
The default behavior can be restored by passing nullptr for the pCallback parameter.
- Parameters
-
pCallback | Function to call when an assert is triggered, nullptr restores defaults |
pThis | void* of data to be passed to the assert function if triggered |
◆ g_Instance
Initial value:= {
nullptr
}
static int default_assert(void *pThis, const char *pCondition, const char *pFilename, uint32_t uLineNumber) noexcept
Default assert function.
Definition brassert.cpp:196
Global instance of the do_assert redirection.
Singleton instance for assert_t.
- See also
- assert_t or assert_t::default_assert
◆ m_pCallback
Function pointer to the redirected do_assert function.
◆ m_pThis
void* Burger::assert_t::m_pThis |
"this" pointer passed to the m_pCallback function