The Debug configuration

Dale,

After creating a project with Rhinoceros 6 Plug-in template, we notice that the Debug configuration has a “NDEBUG” setting. Could we change “NDEBUG” to “_DEBUG” for the Debug configuration? (or this would cause some problems for Rhino plugin?) Many thanks.

Hi @XNurbs,

Please review the Testing section of the Creating your first C/C++ plugin for Rhino guide and let me know if you have any questions.

– Dale

Dale,

We have read the Testing section. Since you set the “NDEBUG” flag for the Debug configuration, we could not use some debug functions, e.g., ASSERT(). Could we switch on the “_DEBUG” flag? (or this would cause some problems for Rhino plugin?)

Hi @XNurbs,

If you created your plug-in using the Rhino plug-in wizard for Visual Studio, then you’ll see this at the bottom of stdafx.h:

#if defined(RHINO_DEBUG_PLUGIN)
// Now that all the system headers are read, we can
// safely define _DEBUG so the developers can test
// for _DEBUG in their code.
#define _DEBUG
#endif

Does this help?

– Dale

Dale,

We would like to use some debug functions, e.g., ASSERT()/_ASSERT(). Defining RHINO_DEBUG_PLUGIN won’t work. So how could we use ASSERT() or _ASSERT() in Rhino plugin? Many thanks.

Hi @XNurbs,

Basically assert is a macro that evaluates the expression and if it fails prints something and then abort s. It’s not that hard to write something similar, something like.

#define ASSERT(x) do { if( !(x) ) { printfunc( #x ); abort(); } while(0)

Then you can modify that in order to suit your requirements. For example you might want not to abort in release mode. You could also adjust your printouts (to include just the information that you think is useful), in order to get file and line information you would use __FILE__ and __LINE__ macros (btw the #x in the define expands to a string literal containing the expression x ).

– Dale