Open CASCADE Technology 6.6.0
Defines | Functions
Standard_Assert.hxx File Reference

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>

Defines

#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.
#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_INVOKE(theDesc)   Standard_ASSERT_INVOKE_(always, theDesc)
 Raise debug message.

Functions

void Standard_ASSERT_DO_NOTHING ()

Detailed Description

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 DEB: 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 macros are formed as functions and require semicolon at the end.


Define Documentation

#define Standard_ASSERT (   theExpr,
  theDesc,
  theAction 
)
Value:
if (!(theExpr)) { theAction; }                     \
    else Standard_ASSERT_DO_NOTHING()
#define Standard_ASSERT_INVOKE (   theDesc)    Standard_ASSERT_INVOKE_(always, theDesc)
#define Standard_ASSERT_INVOKE_ (   theExpr,
  theDesc 
)    Standard_ASSERT_DO_NOTHING()
#define Standard_ASSERT_RAISE (   theExpr,
  theDesc 
)
Value:
Standard_ASSERT(theExpr, theDesc, Standard_ProgramError::Raise(                \
      "*** ERROR: ASSERT in file '" __FILE__ "': \n" theDesc " (" #theExpr ")" ) )
#define Standard_ASSERT_RETURN (   theExpr,
  theDesc,
  theReturnValue 
)    Standard_ASSERT(theExpr, theDesc, return theReturnValue)
#define Standard_ASSERT_SKIP (   theExpr,
  theDesc 
)    theExpr
#define Standard_ASSERT_VOID (   theExpr,
  theDesc 
)    Standard_ASSERT_DO_NOTHING()

Function Documentation

void Standard_ASSERT_DO_NOTHING ( ) [inline]
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines