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.
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?)
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
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.
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.
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 ).