Defines

"Assert macros"

The following macros can be used in 3ds Max plug-ins to assert assumptions made by the plug-in's code. More...

Defines

#define  assert(expr)   ( (expr) || assert1( __LINE__, __FILE__, __FUNCTION__, (#expr) ) )
#define  DbgAssert(expr)   ( (expr) || assert1( __LINE__, __FILE__, __FUNCTION__, (#expr) ) )
#define  DbgVerify(expr)   ( (expr) || assert1( __LINE__, __FILE__, __FUNCTION__, (#expr) ) )
#define  MAX_ASSERTS_ACTIVE

Detailed Description

The following macros can be used in 3ds Max plug-ins to assert assumptions made by the plug-in's code.

Asserts are always enabled in Debug and Hybrid builds, and by default are disabled in release builds. They can be enabled in release builds of a plug-in by defining the MAX_ASSERTS_ACTIVE_IN_RELEASE_BUILD pre-processor symbol. One way to do this is: set CL=/DMAX_ASSERTS_ACTIVE_IN_RELEASE_BUILD

All assert macros below are equivalent. The 32 and 64 bit versions of these macros are also equivalent. The reason why several macros exist are historical... Plug-ins are encouraged to use the DbgAssert macro.

Code that needs to be compiled only when asserts are active (enabled) can be conditionally defined using MAX_ASSERT_ACTIVE. One example when this can be useful is when certain variables are used for debugging purposes only. In this case they can be conditionally declared and updated based on the MAX_ASSERT_ACTIVE symbol, and can be part of expressions that are evaluated in asserts.

 #ifdef MAX_ASSERT_ACTIVE
 int counter = 0;
 // update counter
 #endif
 DbgAssert(counter != 0);

Define Documentation

#define assert (   expr )    ( (expr) || assert1( __LINE__, __FILE__, __FUNCTION__, (#expr) ) )
#define DbgAssert (   expr )    ( (expr) || assert1( __LINE__, __FILE__, __FUNCTION__, (#expr) ) )
#define DbgVerify (   expr )    ( (expr) || assert1( __LINE__, __FILE__, __FUNCTION__, (#expr) ) )
#define MAX_ASSERTS_ACTIVE