This blog does not recommend:
http://blog.kalmbachnet.de/?postid=78
But I still want to do it. I suppose I need to wrap my Debug.Assert with some kind of #ifor #ifdefor something like this. Also, does anyone have a good Debug.Assert example in C++ CLI?
Suppose I have the following variable: String^ validationError = bldError.ToString();
And now I want to do something like:
#if (DEBUG)
Debug.Assert(false, "Got the following validation error:" + validationError);
#endif
How can I do this safely in C++ CLI, and are there any additional fixes to check?
EDIT: Based on the answers, I came up with the following macro:
#ifdef _DEBUG
#define CLIASSERT(condition, ...) System::Diagnostics::Debug::Assert(condition, ##__VA_ARGS__)
#else
#define CLIASSERT(condition, ...)
#endif
And here is a usage example:
String^ strValidationError = bldError.ToString();
CLIASSERT(false, L"Schema validation error: " + strValidationError);
source
share