custom assert that debugger breaks on

Started by
3 comments, last by impulsionaudio 15 years, 2 months ago
I would like to write my own assert that, instead of exiting the program, causes the debugger to break on the assertion failure. I would like a solution that does not require wrapping everything in try/catch blocks. Does anyone know how to write such a thing? Thanks
Advertisement
In Windows, triggering an interrupt 3 will break into the debugger. You can do this within inline assembly or your compiler may have functions to do it. Ex: in MSVC, you can use __debugbreak().
If you use __debugbreak() or int 3, the program will still end if you're not using a debugger. What you can do if open up a dialog box or message box with options, such as "Ok" and "Cancel" where one triggers a breakpoint and the other just attempts to continue the application.
-- gekko
In Visual Studio 2008EE, running the debugger will catch the standard library assert() function. There is no need to use something else.
Thanks for the responses.

This topic is closed to new replies.

Advertisement