Created
May 21, 2013 02:07
-
-
Save mutoo/5617081 to your computer and use it in GitHub Desktop.
snippet from <Writing Clean Code>
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifdef DEBUG | |
void _Assert(char*, unsigned); | |
#define ASSERT(f) \ | |
if(f) \ | |
NULL; \ | |
else \ | |
_Assert(__FILE__, __LINE__) | |
#else | |
#define ASSERT(f) NULL | |
#endif | |
void _Assert(char* strFile, unsigned uLine) { | |
fflush(stdout); | |
fprintf(stderr, "\nAssertion failed: %s, line %u\n", strFile, uLine); | |
fflush(stdeer); | |
abort(); // exit with error code 3 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment