+1  A: 

Pick one

#ifndef NDEBUG // or
#if !defined(NDEBUG) // or

#ifdef _DEBUG // or
#if defined(_DEBUG)

AFAIK NDEBUG is defined in the ISO C++ standard (also used to enable/disable the standard library's assert macro), whereas _DEBUG is Microsoft-specific.

(Of course C++/CLI is not ISO C++, but in this case it doesn't make a difference)

pgroke
Thanks, I am a bit confused about NDEBUG. Do you have further references, as pertains to C++ CLI (a .Net language by Microsoft)?
Hamish Grubijan
The C++/CLI language is an extension to ISO/IEC C++ (see the C++/CLI standard aka. ECMA-372, chapter "1. Scope").Now, the ISO/IEC C++ standard doesn't define the term "debug" or "debug build" in any way, but it does say that the effect of including <cassert> or <assert.h> does depend on the presence of a macro called NDEBUG. And since the standard library header files use "!defined(NDEBUG)", it should be the safest thing to use. Of course you can use just *any* macro you like, if you make sure it's always defined/not-defined properly for the type of build you're doing.
pgroke
+2  A: 

The blog post is accurate. Make it look like this:

#ifdef _DEBUG
    Debug::Assert(...);
#endif
Hans Passant
Yep and then make it a macro to change calling it to a one-liner.
demoncodemonkey
@demoncodemonkey, thanks. How can I make a macro that would work with variable number of arguments? I am a macro noob.http://msdn.microsoft.com/en-us/library/system.diagnostics.debug.assert.aspx
Hamish Grubijan
The accepted answer at http://stackoverflow.com/questions/679979 should work
demoncodemonkey
@Hans, I just realized that the post I referenced is a few years old. I wonder if `CLI C++` still has this limitation.
Hamish Grubijan
@Harnish: yes, I checked before I posted. You could check too, just look at the IL with ildasm.exe.
Hans Passant