src/utils.h

Thu, 10 Feb 2011 01:09:42 +0000

author
Philip Pemberton <philpem@philpem.me.uk>
date
Thu, 10 Feb 2011 01:09:42 +0000
changeset 95
6e01339b218d
parent 89
22198d0a7bef
child 98
d1af20db5f02
permissions
-rw-r--r--

make it possible to eject the floppy disc (use F11!)

philpem@88 1 #ifndef _UTILS_H
philpem@88 2 #define _UTILS_H
philpem@71 3
philpem@89 4 #include <stdio.h>
philpem@89 5
philpem@71 6 #ifndef NDEBUG
philpem@71 7 /// Log a message to stderr
philpem@71 8 # define LOG(x, ...) do { fprintf(stderr, "%s:%d:%s(): " x "\n", __FILE__, __LINE__, __PRETTY_FUNCTION__, ##__VA_ARGS__); } while (0)
philpem@71 9 /// Log a message to stderr if 'cond' is true
philpem@71 10 # define LOG_IF(cond, x, ...) do { if (cond) fprintf(stderr, "%s:%d:%s(): " x "\n", __FILE__, __LINE__, __PRETTY_FUNCTION__, ##__VA_ARGS__); } while (0)
philpem@71 11 #else
philpem@71 12 #define LOG(x, ...)
philpem@71 13 #define LOG_IF(cond, x, ...)
philpem@71 14 #endif
philpem@71 15
philpem@88 16 /// Get the number of elements in an array
philpem@88 17 #define NELEMS(x) (sizeof(x)/sizeof(x[0]))
philpem@88 18
philpem@71 19 #endif // _H_UTILS