C/C++ Library, mos@ua 1.0
cpplib-mos
DbC

Design-by-Contract module for C/C++. More...

Files

file  dbc.h
 Design-by-Contract module.
 

Macros

#define check(condition, message)
 Checks the verification of an general algorithm assertion.
 
#define require(condition, message)
 Checks the verification of a precondition.
 
#define ensure(condition, message)
 Checks the verification of a postcondition.
 
#define invariant(condition, message)
 Checks the verification of an invariant.
 

Detailed Description

Design-by-Contract module for C/C++.

This module gives a better support for DbC in C++.

When compared with assert.h this module offers the following functionalities:

Debug settings:

Author
Miguel Oliveira e Silva
Date
2018, 2026
Version
1.0

Macro Definition Documentation

◆ check

#define check (   condition,
  message 
)

Checks the verification of an general algorithm assertion.

This assertion verification can be disabled at compile time by defining the macro NDEBUG_CHECKS.

Parameters
[in]condition[int] expression to assert its truthness
[in]message[char*] text to be presented with error information when the assertion fails

◆ require

#define require (   condition,
  message 
)

Checks the verification of a precondition.

This assertion verification can be disabled at compile time by defining the macro NDEBUG_PRECONDITIONS.

Parameters
[in]condition[int] expression to assert its truthness
[in]message[char*] text to be presented with error information when the assertion fails

◆ ensure

#define ensure (   condition,
  message 
)

Checks the verification of a postcondition.

This assertion verification can be disabled at compile time by defining the macro NDEBUG_POSTCONDITIONS.

Parameters
[in]condition[int] expression to assert its truthness
[in]message[char*] text to be presented with error information when the assertion fails

◆ invariant

#define invariant (   condition,
  message 
)

Checks the verification of an invariant.

This assertion verification can be disabled at compile time by defining the macro NDEBUG_INVARIANTS.

Parameters
[in]condition[int] expression to assert its truthness
[in]message[char*] text to be presented with error information when the assertion fails