libzypp 17.38.6
precondition.h File Reference

Always-on precondition checking for NG code. More...

Include dependency graph for precondition.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  zyppng
namespace  zyppng::detail

Macros

#define ZYPP_DETAIL_UNLIKELY
 In C++20 and later the violation branch is marked [[unlikely]], giving the optimiser a free hint that it is never expected to be taken.
#define ZYPP_PRECONDITION(EXPR, ...)
 Always-on precondition check — fires in debug AND release builds.

Functions

void zyppng::detail::preconditionViolated (const char *file, int line, const char *func, const char *expr, const char *msg)

Detailed Description

Always-on precondition checking for NG code.

This header is intentionally NOT installed as public API. It is private to the zyppng implementation layer.

Definition in file precondition.h.

Macro Definition Documentation

◆ ZYPP_DETAIL_UNLIKELY

#define ZYPP_DETAIL_UNLIKELY

In C++20 and later the violation branch is marked [[unlikely]], giving the optimiser a free hint that it is never expected to be taken.

In C++17 the attribute is omitted — the macro is otherwise identical.

Definition at line 27 of file precondition.h.

◆ ZYPP_PRECONDITION

#define ZYPP_PRECONDITION ( EXPR,
... )
Value:
do { \
if ( !( EXPR ) ) ZYPP_DETAIL_UNLIKELY \
::zyppng::detail::preconditionViolated( \
__FILE__, __LINE__, __FUNCTION__, #EXPR, "" __VA_ARGS__ ); \
} while ( false )

Always-on precondition check — fires in debug AND release builds.

On violation: logs file / line / function / expression to the INT (internal error) log channel, then calls std::terminate(). The failure is not recoverable and must never be caught.

An optional human-readable message may follow the expression:

ZYPP_PRECONDITION( ptr != nullptr );
ZYPP_PRECONDITION( id != noId, "pool() called on a null handle" );
#define ZYPP_PRECONDITION(EXPR,...)
Always-on precondition check — fires in debug AND release builds.

Definition at line 42 of file precondition.h.