Skip to content

Instantly share code, notes, and snippets.

@nwjsmith
Created March 12, 2009 21:44
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 nwjsmith/78305 to your computer and use it in GitHub Desktop.
Save nwjsmith/78305 to your computer and use it in GitHub Desktop.
Some macros for making system calls less verbose
#define TRY_ASSIGN(v, x) do { \
v = x; \
if (v == -1) { \
fprintf(stderr, # x ": %s\n", strerror(errno)); \
exit(EXIT_FAILURE); \
} \
} while (0)
#define TRY(x) do { int unused; TRY_ASSIGN(unused, x); } while (0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment