From 4d47eb99842b53d3e02d06c189d89e731f8361a3 Mon Sep 17 00:00:00 2001 From: Antti K Date: Tue, 29 Jul 2014 16:49:25 +0200 Subject: Convert simple macros to C99 constants Constants are type-checked; macros aren't. --- compile | 2 +- xkbcat.c | 16 ++++++++-------- 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 #include -#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