CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2004
    Posts
    54

    _ASSERT not working

    I am working with an application that I initially started as a MFC dialog based app. Adding the line _ASSERT(false); works as expected in most parts of the code, but if it's anywhere after the main dialog is closed, then the program shuts down as if the Abort button was pushed on the assert dialog window. For example, if I put _ASSERT(false); at the top of ExitInstance, I will not see the assert dialog at all (but sometimes I hear the windows error sound), and nothing below that line of code will execute. This caused me a lot of trouble trying to track down a bug. I use _ASSERT in a lot of my code, so I would like it to work as it does normally (halt the code, and give me a dialog to choose what to do). How can I fix this?

  2. #2
    Join Date
    Sep 2004
    Location
    Holland (land of the dope)
    Posts
    4,123

    Re: _ASSERT not working

    You can try AfxDebugBreak () instead of _ASSERT(false).

  3. #3
    Join Date
    Mar 2003
    Location
    India {Mumbai};
    Posts
    3,871

    Re: _ASSERT not working

    _ASSERT[E] is from CRT Library. It may have problem detecting the "main" window of MFC-application and making it dialog's parent.

    Use ASSERT. ASSERT macro calls AfxDebugBreak.
    My latest article: Explicating the new C++ standard (C++0x)

    Do rate the posts you find useful.

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