MDL SDK API nvidia_logo_transpbg.gif Up
Math API Assertions

Assertions. More...

Macros

#define mi_math_assert(expr)   mi_base_assert(expr)
 Math API assertion macro (without message). More...
 
#define mi_math_assert_msg(expr, msg)   mi_base_assert_msg(expr, msg)
 Math API assertion macro (with message). More...
 
#define mi_math_assert_enabled
 Indicates whether assertions are actually enabled. More...
 

Detailed Description

Assertions.

Include File:
#include <mi/math/assert.h>

Math API supports quality software development with assertions. They are contained in various places in the math API include files.

These tests are mapped to corresponding base API assertions by default, which in turn are switched off by default to have the performance of a release build. To activate the tests, you need to define the two macros mi_math_assert and mi_math_assert_msg, or correspondingly the mi_base_assert and mi_base_assert_msg macros, before including the relevant include files. Defining only one of the two macros is considered an error.

See also Math API Configuration Options and Base API Configuration Options in general.

Macro Definition Documentation

 mi_math_assert

#define mi_math_assert (   expr)    mi_base_assert(expr)

Math API assertion macro (without message).

If expr evaluates to true this macro shall have no effect. If expr evaluates to false this macro may print a diagnostic message and change the control flow of the program, such as aborting the program or throwing an exception. But it may also have no effect at all, for example if assertions are configured to be disabled.

By default, this macro maps to mi_base_assert, which in turn does nothing by default. You can (re-)define this macro to perform possible checks and diagnostics within the specification given in the previous paragraph.

See also
Math API Configuration Options for Assertions and Base API Configuration Options for Assertions

 mi_math_assert_enabled

#define mi_math_assert_enabled

Indicates whether assertions are actually enabled.

This symbol gets defined if and only if you (re-)defined mi_math_assert and mi_math_assert_msg (or mi_base_assert and mi_base_assert_msg). Note that you can not simply test for mi_math_assert or mi_math_assert_msg, since these macros get defined in any case (if you do not (re-)define them, they evaluate to a dummy statement that has no effect).

 mi_math_assert_msg

#define mi_math_assert_msg (   expr,
  msg 
)    mi_base_assert_msg(expr, msg)

Math API assertion macro (with message).

If expr evaluates to true this macro shall have no effect. If expr evaluates to false this macro may print a diagnostic message and change the control flow of the program, such as aborting the program or throwing an exception. But it may also have no effect at all, for example if assertions are configured to be disabled.

The msg text string contains additional diagnostic information that may be shown with a diagnostic message. Typical usages would contain "precondition" or "postcondition" as clarifying context information in the msg parameter.

By default, this macro maps to mi_base_assert_msg, which in turn does nothing by default. You can (re-)define this macro to perform possible checks and diagnostics within the specification given in the previous paragraph.

See also
Math API Configuration Options for Assertions and Base API Configuration Options for Assertions