Thread: assert

  1. #1
    Registered User
    Join Date
    May 2006


    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,

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Farncombe, Surrey, England
    Here's a couple of links:

    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.

    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Assert command
    By Albinoswordfish in forum C Programming
    Replies: 14
    Last Post: 12-24-2008, 09:03 PM
  2. Can you check what is wrong with this code
    By Ron in forum C++ Programming
    Replies: 4
    Last Post: 08-01-2008, 10:59 PM
  3. Customized assert question...
    By Raigne in forum C++ Programming
    Replies: 10
    Last Post: 02-21-2008, 04:28 AM
  4. Assert
    By Shamino in forum C++ Programming
    Replies: 8
    Last Post: 01-24-2006, 11:02 AM
  5. How to use assert?
    By jjbuchan in forum C Programming
    Replies: 2
    Last Post: 11-11-2005, 01:40 PM