-
assert
Hello everyone,
I saw a couple of form of assert in code on Windows,
1. ASSERT;
2. assert;
3. _ASSERT;
4. _assert.
Which one is the most correct to use? I saw people always define this to that, and I want to find the root one which is defined by Windows.
I also saw people manually define assert to NULL if macro DEBUG or _DEBUG is not defined, is that necessary?
I feel assert is in a mess and I want to find a clear and unified way for this item.
thanks in advance,
George
-
Here's a couple of links:
http://msdn2.microsoft.com/en-us/lib...ez(VS.80).aspx
http://msdn2.microsoft.com/en-us/lib...w4(VS.71).aspx
http://msdn2.microsoft.com/en-us/lib...fa(vs.71).aspx
assert is defined to "nothing" when NDEBUG is set. It may be that NDEBUG isn't strictly connected with _DEBUG or DEBUG, which may explain the #if statements you see - or someone has had some buggy/strange implementation of assert.h (or wherever the ASSERT came from)
I don't like calling a "nothing" define NULL since it can be confused with the NULL that is used for pointers and such, or '\0' - empty is another option.
--
Mats