summaryrefslogtreecommitdiff
path: root/common.h
diff options
context:
space:
mode:
authorBobby Bingham <koorogi@koorogi.info>2017-01-19 19:11:54 -0600
committerBobby Bingham <koorogi@koorogi.info>2017-01-19 19:11:54 -0600
commitf07d5cdbaf5d906b145b152d549915271d355798 (patch)
tree74ca01e5ccf06c67ac25e769f5c4a3f71aa7bbe6 /common.h
parent7561230a9dda9728b93306c0bd398c5b1cc1ce4d (diff)
nqasm: add command line processing
Diffstat (limited to 'common.h')
-rw-r--r--common.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/common.h b/common.h
new file mode 100644
index 0000000..82a6328
--- /dev/null
+++ b/common.h
@@ -0,0 +1,24 @@
+#ifndef NQ_COMMON_H
+#define NQ_COMMON_H
+
+#include <errno.h>
+#include <stdio.h>
+
+extern const char *progname;
+
+#define ERROR(...) \
+ do { \
+ fprintf(stderr, "%s: ", progname); \
+ fprintf(stderr, __VA_ARGS__); \
+ fprintf(stderr, "\n"); \
+ } while (0)
+
+#define PERROR(str) \
+ do { \
+ int err = errno; \
+ fprintf(stderr, "%s: ", progname); \
+ errno = err; \
+ perror(str); \
+ } while (0)
+
+#endif