Skip to content

Instantly share code, notes, and snippets.

@mutoo
Created May 21, 2013 02:07
Show Gist options
  • Save mutoo/5617081 to your computer and use it in GitHub Desktop.
Save mutoo/5617081 to your computer and use it in GitHub Desktop.
snippet from <Writing Clean Code>
#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