fsAssert.h brings extended versions of the default assert macro, which is typically used to identify logical errors in the debug mode during the development. If you are not familiar with the concept, please check a relevant documentation.
Following macros are provided:
In the debug mode - if the expression is evaluated to false then FS_ASSERT and FS_ASSERT_MSG invoke an information box showing information about the expression and the exact code position. In the message version a user message is printed as well. By pressing one of the buttons in the box it is possible to choose whether or not should be the execution terminated. In the case of FS_ASSERT_BEEP only a sound is played and there is no way to stop the execution (this behaviour is especially useful in runtime environments when the assert is invoked within a loop and pressing a button every time would be annoying).
FS_VERIFY_... macros are used similarly, the only difference is the expression is always evaluated! (but the result is not checked in the release mode).
The last variant FS_STATIC_ASSERT is used for compile-time tests e.g. FS_STATIC_ASSERT(sizeof(T) == 24);
The main advantage of the information box is that the error information is available during testing where there is no development environment involved to catch the bug directly by a programmer.
Definition in file fsAssert.h.
Go to the source code of this file.
Namespaces | |
namespace | fs |
namespace | fs::sys |
namespace | fs::sys::asr |
Classes | |
struct | FS_STATIC_ASSERT___E_R_R_O_R___< true > |
Helper template for compile-time error checking. More... | |
Defines | |
#define | FS_ASSERT_LABEL "FIPS' ASSERT WARNING" |
Set: Information box label. | |
#define | FS_ASSERT_ENABLE_BOX |
Enable: Standard (box) version. | |
#define | FS_ASSERT_ENABLE_BEEP |
Enable: Beep version. | |
#define | __FUNCTION__ "???" |
#define | FS_ASSERT_BREAK __asm int 3 |
Runtime break code (for internal use only). | |
#define | FS_ASSERT_MSG(exp, msg) |
A message version of the assert macro. | |
#define | FS_ASSERT(exp) FS_ASSERT_MSG(exp, 0) |
Assert macro. | |
#define | FS_ASSERT_BEEP(exp) |
A beep version of the assert macro. | |
#define | FS_VERIFY(exp) FS_ASSERT(exp) |
Verify macro. | |
#define | FS_VERIFY_MSG(exp, msg) FS_ASSERT_MSG(exp, msg) |
A message version of the verify macro. | |
#define | FS_VERIFY_BEEP(exp) FS_ASSERT_BEEP(exp) |
A beep version of the verify macro. | |
#define | FS_STATIC_ASSERT(exp) ( (FS_STATIC_ASSERT___E_R_R_O_R___<(exp) != 0>()) ) |
A compile-time assert macro. | |
Functions | |
bool | fs::sys::asr::BoxWin (const char *, const char *, const char *, const char *, int) |
Invokes a message box on Windows platforms (for internal use only). | |
void | fs::sys::asr::BeepWin () |
Beeps on Windows platforms (for internal use only). |
#define __FUNCTION__ "???" |
Definition at line 103 of file fsAssert.h.
#define FS_ASSERT | ( | exp | ) | FS_ASSERT_MSG(exp, 0) |
#define FS_ASSERT_BEEP | ( | exp | ) |
Value:
{ \ bool bExp = (exp) ? true : false; \ if(!bExp) fs::sys::asr::BeepWin(); \ }
Definition at line 154 of file fsAssert.h.
#define FS_ASSERT_BREAK __asm int 3 |
#define FS_ASSERT_ENABLE_BEEP |
Enable: Beep version.
If this directive is defined, it enables the beep versions of FS_ASSERT_... / FS_VERIFY_... (typically in the debug mode). Otherwise the checking is disabled. Note that in the case of FS_VERIFY_... the expression is always evaluated!
Definition at line 96 of file fsAssert.h.
#define FS_ASSERT_ENABLE_BOX |
Enable: Standard (box) version.
If this directive is defined, it enables the message versions of FS_ASSERT_... / FS_VERIFY_... (typically in the debug mode). Otherwise the checking is disabled. Note that in the case of FS_VERIFY_... the expression is always evaluated!
Definition at line 90 of file fsAssert.h.
#define FS_ASSERT_LABEL "FIPS' ASSERT WARNING" |
Set: Information box label.
By defining this directive (a string literal), it is possible to customize the label of the information box.
Definition at line 84 of file fsAssert.h.
#define FS_ASSERT_MSG | ( | exp, | |||
msg | ) |
Value:
{ \ bool bExp = (exp) ? true : false; \ if(!bExp && fs::sys::asr::BoxWin(#exp, msg, __FUNCTION__, \ __FILE__, __LINE__)) FS_ASSERT_BREAK \ }
Definition at line 137 of file fsAssert.h.
#define FS_STATIC_ASSERT | ( | exp | ) | ( (FS_STATIC_ASSERT___E_R_R_O_R___<(exp) != 0>()) ) |
A compile-time assert macro.
If a test fails, 'FS_STATIC_ASSERT___E_R_R_O_R___' typically appears in the compiler error output.
Definition at line 187 of file fsAssert.h.
#define FS_VERIFY | ( | exp | ) | FS_ASSERT(exp) |
#define FS_VERIFY_BEEP | ( | exp | ) | FS_ASSERT_BEEP(exp) |
A beep version of the verify macro.
Definition at line 179 of file fsAssert.h.
#define FS_VERIFY_MSG | ( | exp, | |||
msg | ) | FS_ASSERT_MSG(exp, msg) |
A message version of the verify macro.
Definition at line 173 of file fsAssert.h.