Last active
February 13, 2016 16:58
-
-
Save P1kachu/3cb0d175ee8762247fdf to your computer and use it in GitHub Desktop.
Errno printer (C/C++)
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
#include <errno.h> | |
#include <string.h> | |
#define NONE "\033[0m" | |
#define RED "\033[31m" | |
# define print_errno() \ | |
{ \ | |
if (errno) \ | |
{ \ | |
fprintf(stdout, "%sERROR%s Something went wrong: %s (%s%s%s:%d)\n", \ | |
RED, NONE, strerror(errno), RED, __FILE__, NONE, __LINE__); \ | |
exit(-1); \ | |
} \ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment