LibreOffice
LibreOffice 24.2 SDK C/C++ API Reference
Macros
Assertions

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

Macros

#define OSL_ASSERT(c)   SAL_DETAIL_WARN_IF_FORMAT(!(c), "legacy.osl", "OSL_ASSERT: %s", #c)
 If cond is false, reports an error. More...
 
#define OSL_ENSURE(c, m)   SAL_DETAIL_WARN_IF_FORMAT(!(c), "legacy.osl", "%s", m)
 If cond is false, reports an error with message msg. More...
 
#define OSL_FAIL(m)   SAL_DETAIL_WARN_IF_FORMAT(sal_True, "legacy.osl", "%s", m)
 Reports an error with message msg unconditionally. More...
 
#define OSL_VERIFY(c)   do { if (!(c)) OSL_ASSERT(0); } while (0)
 Evaluates the expression and if it is false, reports an error. More...
 
#define OSL_PRECOND(c, m)   OSL_ENSURE(c, m)
 Check the precondition of functions. More...
 
#define OSL_POSTCOND(c, m)   OSL_ENSURE(c, m)
 Check the postcondition of functions. More...
 

Detailed Description

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

Macro Definition Documentation

◆ OSL_ASSERT

#define OSL_ASSERT (   c)    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,
 
)    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)    SAL_DETAIL_WARN_IF_FORMAT(sal_True, "legacy.osl", "%s", m)

Reports an error with message msg unconditionally.

◆ OSL_POSTCOND

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

Check the postcondition of functions.

Functionally equivalent to OSL_ENSURE(cond, msg).

◆ OSL_PRECOND

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

Check the precondition of functions.

Functionally equivalent to OSL_ENSURE(cond, msg).

◆ OSL_VERIFY

#define OSL_VERIFY (   c)    do { if (!(c)) OSL_ASSERT(0); } while (0)

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);
}