summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorGravatar Antti K2014-07-29 16:49:25 +0200
committerGravatar Antti K2014-07-29 20:35:36 +0200
commit4d47eb99842b53d3e02d06c189d89e731f8361a3 (patch)
tree8ab427757132a8a6caae4031f145108bd334c540
parentc12aa06f8022fb9cb08b1e65dfed06aa4d8815f1 (diff)
downloadxkbcat-4d47eb99842b53d3e02d06c189d89e731f8361a3.tar.gz
xkbcat-4d47eb99842b53d3e02d06c189d89e731f8361a3.zip
Convert simple macros to C99 constants
Constants are type-checked; macros aren't.
-rwxr-xr-xcompile2
-rw-r--r--xkbcat.c16
2 files changed, 9 insertions, 9 deletions
diff --git a/compile b/compile
index 5e1dc51..16df9d3 100755
--- a/compile
+++ b/compile
@@ -1 +1 @@
-clang -o xkbcat -lX11 xkbcat.c
+clang --std=c11 -Wall -o xkbcat -lX11 xkbcat.c
diff --git a/xkbcat.c b/xkbcat.c
index 04bb82c..8702e92 100644
--- a/xkbcat.c
+++ b/xkbcat.c
@@ -22,13 +22,13 @@
#include <stdlib.h>
#include <unistd.h>
-#define DEFAULT_DISPLAY ":0"
-#define DEFAULT_DELAY 10000
-#define BIT(c, x) ( c[x/8]& (1<<(x%8)) )
-#define TRUE 1
-#define FALSE 0
+const int TRUE = 1;
+const int FALSE = 0;
-#define KEYSYM_STRLEN 64
+char *DEFAULT_DISPLAY = ":0";
+const int DEFAULT_DELAY = 10000;
+#define BIT(c, x) ( c[x/8]& (1<<(x%8)) )
+const int KEYSYM_STRLEN = 64;
/* Globals */
Display *disp;
@@ -52,7 +52,7 @@ int main(int argc, char *argv[]) {
buf1[32], buf2[32],
*keys,
*saved;
- int i, delay = DEFAULT_DELAY;
+ int i, delay = DEFAULT_DELAY;
/* get args */
for (i=1; i<argc; i++) {
@@ -110,7 +110,7 @@ int main(int argc, char *argv[]) {
*/
char *KeyCodeToStr(int code, int down) {
- static char *str, buf[KEYSYM_STRLEN+1];
+ static char *str, buf[KEYSYM_STRLEN + 1];
KeySym keysym = XKeycodeToKeysym(disp, code, 0);
if (NoSymbol == keysym) return "";