VR-Vantage
Loading...
Searching...
No Matches
DtContractAssert.h File Reference

Development-only contract assertion macro for optimized builds. More...

Go to the source code of this file.

Macros

#define VRV_CONTRACT_ASSERT(expr)
 Compiles to nothing when contract asserts are disabled (default).

Detailed Description

Development-only contract assertion macro for optimized builds.

VRV_CONTRACT_ASSERT(expr) is a lightweight precondition/postcondition check intended for use during development. It validates assumptions at API boundaries, state transitions, and other non-trivial call sites.

This macro is NOT intended for inner loops or performance-critical code. It exists to catch contract violations early during development without requiring a full debug build.

Behavior:

  • When VRV_CONTRACT_ASSERT_ENABLED is defined (via the build system), a failed expression triggers a debugger break at the call site.
  • When VRV_CONTRACT_ASSERT_ENABLED is NOT defined (the default), the macro compiles to nothing. Zero runtime cost.

To enable:

  1. Uncomment "set VRV_ENABLE_CONTRACT_ASSERT=1" in dev/env.bat
  2. Re-run configure.bat to regenerate the build

The assert fires regardless of NDEBUG, so it works in RelWithDebInfo builds.

Macro Definition Documentation

◆ VRV_CONTRACT_ASSERT

#define VRV_CONTRACT_ASSERT ( expr)
Value:
((void)0)

Compiles to nothing when contract asserts are disabled (default).