LibreOffice: Assertions

LibreOffice LibreOffice 26.8 SDK C/C++ API Reference

Loading...
Searching...
No Matches
Assertions

Assertions (cond is bool, msg is char*). More...

## Macros
#define | OSL_ASSERT(c)
| If cond is false, reports an error.
#define | OSL_ENSURE(c, m)
| If cond is false, reports an error with message msg.
#define | OSL_FAIL(m)
| Reports an error with message msg unconditionally.
#define | OSL_VERIFY(c)
| Evaluates the expression and if it is false, reports an error.
#define | OSL_PRECOND(c, m)
| Check the precondition of functions.
#define | OSL_POSTCOND(c, m)
| Check the postcondition of functions.

## Detailed Description

Assertions (cond is bool, msg is char*).

## Macro Definition Documentation

## ◆ OSL_ASSERT

#define OSL_ASSERT | ( |  | c | ) |

Value:
SAL_DETAIL_WARN_IF_FORMAT(!(c), "legacy.osl", "OSL_ASSERT: %s", #c)

If cond is false, reports an error.

## ◆ OSL_ENSURE

#define OSL_ENSURE | ( |  | c,
|  |  | m )

Value:
SAL_DETAIL_WARN_IF_FORMAT(!(c), "legacy.osl", "%s", m)

If cond is false, reports an error with message msg.

## ◆ OSL_FAIL

#define OSL_FAIL | ( |  | m | ) |

Value:
SAL_DETAIL_WARN_IF_FORMAT(sal_True, "legacy.osl", "%s", m)
sal_True
#define sal_True
Definition types.h:40

Reports an error with message msg unconditionally.

## ◆ OSL_POSTCOND

#define OSL_POSTCOND | ( |  | c,
|  |  | m )

Value:
OSL_ENSURE(c, m)
OSL_ENSURE
#define OSL_ENSURE(c, m)
If cond is false, reports an error with message msg.
Definition diagnose.h:87

Check the postcondition of functions.

Functionally equivalent to OSL_ENSURE(cond, msg).

## ◆ OSL_PRECOND

#define OSL_PRECOND | ( |  | c,
|  |  | m )

Value:
OSL_ENSURE(c, m)

Check the precondition of functions.

Functionally equivalent to OSL_ENSURE(cond, msg).

## ◆ OSL_VERIFY

#define OSL_VERIFY | ( |  | c | ) |

Value:
do { if (!(c)) OSL_ASSERT(0); } while (0)
OSL_ASSERT
#define OSL_ASSERT(c)
If cond is false, reports an error.
Definition diagnose.h:84

Evaluates the expression and if it is false, reports an error.

The expression is evaluated once without regard of the value of OSL_DEBUG_LEVEL.

Example:

void extractBool(Any const& rAny, bool& rBool)
{
OSL_VERIFY(rAny >>= rBool);
}
OSL_VERIFY
#define OSL_VERIFY(c)
Evaluates the expression and if it is false, reports an error.
Definition diagnose.h:106