Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

customizing assert macro

On Windows/c++, I want to customize the assert dialog box to ignore an assertion forever, so I can be more aggressive with assertions. I understand how hard it is to write a correct assert macro, and do not wish to do this, just hook the dialog code. Is there an easy way (or concise hack) to do this?

article on assert macro dangers (googlecache)

update: more aggressive => use far more frequently and for noncrash bugs. I want to be able to ignore an assertion forever so if a minor bug assertion occurs in a loop it doesn't effectively halt my process.

like image 671
Dustin Getz Avatar asked Jun 27 '26 18:06

Dustin Getz


2 Answers

Look into the _CrtSetReportHook function or the newer _CrtSetReportHook2. You can use it to install a hook that remembers "seen" messages, and reports them as handled when seen again.

like image 62
Andrew Stein Avatar answered Jun 30 '26 06:06

Andrew Stein


If by "more aggressive" you mean using assertions for error handling, then you're better off using exceptions.

like image 43
Assaf Lavie Avatar answered Jun 30 '26 08:06

Assaf Lavie



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!