On Error Checking
Thursday, July 15th, 2010My new favorite coding trick is as follows:
#ifdef _DEBUG
assert( something );
#endif
In terms of error-checking, there are couple interesting things about this code. Firstly, as can be seen, this code is only compiled in Debug mode. This results in faster performing code in Release mode, since we’re removing some of it. But the more curious part is that there are no error conditions here to trap, really.
When in debug mode, the program execution stops here, and forces you to address the problem such that it does not occur. (more…)

