Skip to content

Instantly share code, notes, and snippets.

@alesegdia
Created March 23, 2016 01:18
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 alesegdia/fb9aa5b93f4027416bea to your computer and use it in GitHub Desktop.
Save alesegdia/fb9aa5b93f4027416bea to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <assert.h>
/**
* http://c.learncodethehardway.org/book/ex20.html
*/
#define clean_errno() (errno == 0 ? "None" : strerror(errno))
#define log_error(M, ...) fprintf(stderr, "[ERROR] (%s:%d: errno: %s) " M "\n", __FILE__, __LINE__, clean_errno(), ##__VA_ARGS__)
#define assertf(A, M, ...) if(!(A)) {log_error(M, ##__VA_ARGS__); exit(1); }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment