Sign in to follow this  
impulsionaudio

custom assert that debugger breaks on

Recommended Posts

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

Share this post


Link to post
Share on other sites
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().

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this