Share via


XMASSERT Macro

Provides support for debugging a program or game title by evaluating a specified logical condition; if the condition is false, the appropriate assert handler is invoked and the program or game title is aborted.

Syntax

#if defined(_PREFAST_)
#define XMASSERT(Expression) __analysis_assume((Expression))
#elif defined(XMDEBUG) // !_PREFAST_
#define XMASSERT(Expression) ((VOID)((Expression) || (XMAssert(#Expression, __FILE__, __LINE__), 0)))
#else // !XMDEBUG
#define XMASSERT(Expression) ((VOID)0)
#endif // !XMDEBUG

Parameters

  • Expression
    [in] Specifies any logical expression. If the expression evaluates to FALSE, the code is halted.

Return Value

#if defined(_PREFAST_) #define XMASSERT(Expression) __analysis_assume((Expression)) #elif defined(XMDEBUG) // !_PREFAST_ #define XMASSERT(Expression) ((VOID)((Expression) || (XMAssert(#Expression, __FILE__, __LINE__), 0))) #else // !XMDEBUG #define XMASSERT(Expression) ((VOID)0) #endif // !XMDEBUG

None

Remarks

XMASSERT will active only if source is compiled with debugging enabled (or the _DEBUG directive defined), or if the code is compiled under prefast.

For ordinary debugging, the XNA Math function XMAssert is the assert handler.

When compiled under prefast, the __analysis_assume function is the handler for asserts.

Requirements

Header: Declared in xnamath.h.

See Also

XMAssert
__analysis_assume
prefast