OCCT 8.0.1
OCCT documentation

Search guides and API reference

Enter at least two characters.

    Open CASCADE Technology Reference Manual 8.0.1
    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...

    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)
    #define Standard_ASSERT(theExpr, theDesc, theAction)
    #define Standard_ASSERT_SKIP(theExpr, theDesc)
    #define Standard_ASSERT_VOID(theExpr, theDesc)
    #define Standard_ASSERT_RAISE(theExpr, theDesc)
     Raise exception (Standard_ProgramError) with the provided message.
    #define Standard_VOID_RETURN
     Empty return value for use with Standard_ASSERT_RETURN in void functions. Using this macro instead of empty argument prevents clang-tidy from corrupting the code.
    #define Standard_ASSERT_RETURN(theExpr, theDesc, theReturnValue)
     Return from the current function with specified value. Use Standard_VOID_RETURN as theReturnValue for void functions.
    #define Standard_ASSERT_INVOKE(theDesc)
     Raise debug message.
    #define Standard_STATIC_ASSERT(theExpr)
     Cause compiler error if argument is not constant expression or evaluates to false.

    Functions

    void Standard_ASSERT_DO_NOTHING ()

    Detailed Description

    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:

    • Standard_ASSERT_RAISE: raises exception Standard_ProgramError
    • Standard_ASSERT_RETURN: returns specified value (last argument may be left empty to return void)
    • Standard_ASSERT_SKIP: does nothing
    • Standard_ASSERT_VOID: does nothing; even does not evaluate first arg when in Release mode
    • Standard_ASSERT_INVOKE: causes unconditional assert
    • Standard_ASSERT: base macro (used by other macros); does operation indicated in argument "todo"

    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:

    • on Windows (under VC++), stops code execution and prompts to attach debugger to the process immediately.
    • on POSIX systems, prints message to cerr and raises signal SIGTRAP to stop execution when under debugger (may terminate the process if not under debugger).

    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.

    Macro Definition Documentation

    ◆ Standard_ASSERT

    #define Standard_ASSERT ( theExpr,
    theDesc,
    theAction )
    Value:
    if (!(theExpr)) \
    { \
    theAction; \
    } \
    else \
    Standard_ASSERT_DO_NOTHING()

    ◆ Standard_ASSERT_INVOKE

    #define Standard_ASSERT_INVOKE ( theDesc)
    Value:
    Standard_ASSERT_INVOKE_(always, theDesc)
    #define Standard_ASSERT_INVOKE_(theExpr, theDesc)
    Definition Standard_Assert.hxx:155

    Raise debug message.

    ◆ Standard_ASSERT_INVOKE_

    #define Standard_ASSERT_INVOKE_ ( theExpr,
    theDesc )
    Value:
    void Standard_ASSERT_DO_NOTHING()
    Definition Standard_Assert.hxx:70

    ◆ Standard_ASSERT_RAISE

    #define Standard_ASSERT_RAISE ( theExpr,
    theDesc )
    Value:
    Standard_ASSERT(theExpr, \
    theDesc, \
    throw Standard_ProgramError("*** ERROR: ASSERT in file '" __FILE__ \
    "': \n" theDesc " (" #theExpr ")"))
    #define Standard_ASSERT(theExpr, theDesc, theAction)
    Definition Standard_Assert.hxx:158

    Raise exception (Standard_ProgramError) with the provided message.

    ◆ Standard_ASSERT_RETURN

    #define Standard_ASSERT_RETURN ( theExpr,
    theDesc,
    theReturnValue )
    Value:
    Standard_ASSERT(theExpr, theDesc, return theReturnValue)

    Return from the current function with specified value. Use Standard_VOID_RETURN as theReturnValue for void functions.

    ◆ Standard_ASSERT_SKIP

    #define Standard_ASSERT_SKIP ( theExpr,
    theDesc )
    Value:
    theExpr

    ◆ Standard_ASSERT_VOID

    #define Standard_ASSERT_VOID ( theExpr,
    theDesc )

    ◆ Standard_STATIC_ASSERT

    #define Standard_STATIC_ASSERT ( theExpr)
    Value:
    Static assert – empty default template.
    Definition Standard_Assert.hxx:195

    Cause compiler error if argument is not constant expression or evaluates to false.

    ◆ Standard_VOID_RETURN

    #define Standard_VOID_RETURN

    Empty return value for use with Standard_ASSERT_RETURN in void functions. Using this macro instead of empty argument prevents clang-tidy from corrupting the code.

    Function Documentation

    ◆ Standard_ASSERT_DO_NOTHING()

    void Standard_ASSERT_DO_NOTHING ( )
    inline