CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    George2 is offline Elite Member Power Poster
    Join Date
    Oct 2002
    Posts
    4,468

    Talking A question about the precompiled directive ASSERT

    Hi, everyone!

    Please look at the following code,

    --------
    #if ASSERT
    sprintf (s, "_Assert: %s, %d",__FILE__, __LINE__ );
    #else
    //...
    #endif
    --------

    I want to know where is the precompiled directive ASSERT defined?
    Is it compiler system defined variable? What is the meaning and
    function of it?


    Thanks in advance,
    George

  2. #2
    Join Date
    May 2000
    Location
    Phoenix, AZ [USA]
    Posts
    1,347
    It depends on your compiler; it's my understanding that ASSERT
    isn't part of the C standard so using it might be nonportable
    [as opposed to assert(), which should be portable]. Anyway,
    in my compiler, ASSERT is #define'd in crtdbg.h, afx.h, and I'm sure
    it's #define'd other ways in other places as well. Do a grep or
    similar search through your compiler's header files and find out
    for yourself where it'll be #define'd on your system.

    --Paul

  3. #3
    George2 is offline Elite Member Power Poster
    Join Date
    Oct 2002
    Posts
    4,468

    Talking

    Thanks!

    George
    Originally posted by PaulWendt
    It depends on your compiler; it's my understanding that ASSERT
    isn't part of the C standard so using it might be nonportable
    [as opposed to assert(), which should be portable]. Anyway,
    in my compiler, ASSERT is #define'd in crtdbg.h, afx.h, and I'm sure
    it's #define'd other ways in other places as well. Do a grep or
    similar search through your compiler's header files and find out
    for yourself where it'll be #define'd on your system.

    --Paul

  4. #4
    Join Date
    Sep 2000
    Location
    Russia
    Posts
    262
    Moreover, ASSERT is a non-standard Microsoft MFC substitution for standard C assert macro. Nota bene, ASSERT is in effect only when the MFC macro _DEBUG defined, opposed to assert, which depends on the standard NDEBUG macro.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured