Skip to content

Instantly share code, notes, and snippets.

@alisdair
Created November 25, 2011 11:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alisdair/1393322 to your computer and use it in GitHub Desktop.
Save alisdair/1393322 to your computer and use it in GitHub Desktop.
logger_assert: macro to die when an expression is false, printing the function name, expression, file, and line
#define STR(x) #x
#define STRINGIFY(x) STR(x)
#define LINESTR STRINGIFY(__LINE__)
#define logger_assert(x) if (!(x)) logger_die("%s: assertion failed: " #x \
" (" __FILE__ ", line " LINESTR \
")", __func__)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment