Open CASCADE Technology
7.5.0
|
This header file defines a set of ASSERT macros intended for use in algorithms for debugging purposes and as a tool to organise checks for abnormal situations in the uniform way. More...
#include <Standard_ProgramError.hxx>
Data Structures | |
struct | Standard_Static_Assert< condition > |
Static assert – empty default template. More... | |
struct | Standard_Static_Assert< true > |
Static assert – specialization for condition being true. More... | |
Macros | |
#define | Standard_ASSERT_INVOKE_(theExpr, theDesc) Standard_ASSERT_DO_NOTHING() |
#define | Standard_ASSERT(theExpr, theDesc, theAction) |
#define | Standard_ASSERT_SKIP(theExpr, theDesc) theExpr |
#define | Standard_ASSERT_VOID(theExpr, theDesc) Standard_ASSERT_DO_NOTHING() |
#define | Standard_ASSERT_RAISE(theExpr, theDesc) |
Raise exception (Standard_ProgramError) with the provided message. More... | |
#define | Standard_ASSERT_RETURN(theExpr, theDesc, theReturnValue) Standard_ASSERT(theExpr, theDesc, return theReturnValue) |
Return from the current function with specified value (empty if the function returns void) More... | |
#define | Standard_ASSERT_INVOKE(theDesc) Standard_ASSERT_INVOKE_(always, theDesc) |
Raise debug message. More... | |
#define | Standard_STATIC_ASSERT(theExpr) Standard_Static_Assert<theExpr>::assert_ok(); |
Cause compiler error if argument is not constant expression or evaluates to false. More... | |
Functions | |
void | Standard_ASSERT_DO_NOTHING () |
This header file defines a set of ASSERT macros intended for use in algorithms for debugging purposes and as a tool to organise checks for abnormal situations in the uniform way.
In contrast to C assert() function that terminates the process, these macros provide choice of the action to be performed if assert failed, thus allowing execution to continue when possible. Except for the message for developer that appears only in Debug mode, the macros behave in the same way in both Release and Debug modes.
The ASSERT macros differ in the way they react on a wrong situation:
The assertion is assumed to fail if the first argument is evaluated to zero (false). The first argument is evaluated by all macros except Standard_ASSERT_VOID which does not evaluate first argument when in Release mode. The mode is triggered by preprocessor macro _DEBUG: if it is defined, Debug mode is assumed, Release otherwise.
In debug mode, if condition is not satisfied the macros call Standard_ASSERT_INVOKE_ which:
The second argument (message) should be string constant ("...").
The Standard_STATIC_ASSERT macro is to be used for compile time checks. To use this macro, write:
Standard_STATIC_ASSERT(const_expression);
If const_expression is false, a compiler error occurs.
The macros are formed as functions and require semicolon at the end.
#define Standard_ASSERT | ( | theExpr, | |
theDesc, | |||
theAction | |||
) |
#define Standard_ASSERT_INVOKE | ( | theDesc | ) | Standard_ASSERT_INVOKE_(always, theDesc) |
Raise debug message.
#define Standard_ASSERT_INVOKE_ | ( | theExpr, | |
theDesc | |||
) | Standard_ASSERT_DO_NOTHING() |
#define Standard_ASSERT_RAISE | ( | theExpr, | |
theDesc | |||
) |
Raise exception (Standard_ProgramError) with the provided message.
#define Standard_ASSERT_RETURN | ( | theExpr, | |
theDesc, | |||
theReturnValue | |||
) | Standard_ASSERT(theExpr, theDesc, return theReturnValue) |
Return from the current function with specified value (empty if the function returns void)
#define Standard_ASSERT_SKIP | ( | theExpr, | |
theDesc | |||
) | theExpr |
#define Standard_ASSERT_VOID | ( | theExpr, | |
theDesc | |||
) | Standard_ASSERT_DO_NOTHING() |
#define Standard_STATIC_ASSERT | ( | theExpr | ) | Standard_Static_Assert<theExpr>::assert_ok(); |
Cause compiler error if argument is not constant expression or evaluates to false.
|
inline |