Container structure for Assert support.
More...
|
typedef int(*) | CallbackProc(void *pThis, const char *pCondition, const char *pFilename, uint32_t uLineNumber) |
| Redirect an assert to the application's assert function.
|
|
|
static int | DefaultAssert (void *pThis, const char *pCondition, const char *pFilename, uint32_t uLineNumber) noexcept |
| Default assert function.
|
|
Container structure for Assert support.
This global assert structure is used for supporting the ability to redirect an Assert(const char *,const char *,uint32_t) call.
- See also
- Assert(const char *,const char *,uint32_t), or BURGER_ASSERT
◆ CallbackProc
int( *) Burger::Assert_t::CallbackProc(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
◆ DefaultAssert()
int BURGER_API Burger::Assert_t::DefaultAssert |
( |
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 Assert(
const char *,const char *,uint32_t)
◆ SetCallback()
Overrides the default Assert function.
The normal behavior for 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 pAssert 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 DefaultAssert(void *pThis, const char *pCondition, const char *pFilename, uint32_t uLineNumber) noexcept
Default assert function.
Definition brassert.cpp:198
Global instance of the Assert redirection.
Singleton instance for Assert_t.
- See also
- Assert_t or Assert_t::DefaultAssert
◆ m_pCallback
Function pointer to the redirected Assert function.
◆ m_pThis
void* Burger::Assert_t::m_pThis |
"this" pointer passed to the m_pProcAssert function