Skip to content

Instantly share code, notes, and snippets.

@P1kachu
Last active February 13, 2016 16:58
Show Gist options
  • Save P1kachu/3cb0d175ee8762247fdf to your computer and use it in GitHub Desktop.
Save P1kachu/3cb0d175ee8762247fdf to your computer and use it in GitHub Desktop.
Errno printer (C/C++)
#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