You are not logged in.
Hello!
I am using snapwm, which is partly configured using a config.h. I would like to define a command in this config which takes 2 hex colour codes (e.g., #483839) as arguments so that I can later assign a keybinding to it. But I get error messages or warnings while compiling, it seems because of the '#' in the colour codes. Is there a way to 'escape' these hash signs to avoid the warnings and/or errors?
Here is the line in question:
const char* gradrnd = {"gradrnd","'#000000'","'#444400'",NULL};
Last edited by hellomynameisphil (2012-02-21 00:21:00)
Offline
It's not from the hash sign. It's because you're defining that as a char *, but you are intializing it as something else.
Try
const char* gradrnd[] = {"gradrnd","'#000000'","'#444400'",NULL};
2nd Edit: portix beat me to it.
Last edited by Trilby (2012-02-19 23:47:31)
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
You don't have to escape it, your declaration is wrong, you can change it to
const char *gradrnd[] = {"gradrnd","'#000000'","'#444400'",NULL};
Offline
Thanks portix. Still getting warning msgs. Here is the whole file:
http://paste.lisp.org/display/127876
When I run 'make', I get:
gcc -Wall -c -o snapwm.o snapwm.c
In file included from snapwm.c:144:0:
config.h:65:1: warning: excess elements in scalar initializer
config.h:65:1: warning: (near initialization for 'gradrnd')
config.h:65:1: warning: excess elements in scalar initializer
config.h:65:1: warning: (near initialization for 'gradrnd')
config.h:65:1: warning: excess elements in scalar initializer
config.h:65:1: warning: (near initialization for 'gradrnd')
gcc -s -Os -o snapwm snapwm.o -lX11
I don't get these warnings with the gradrnd line commented out.
Offline
The file you linked misses a set of braces.
const char *gradrnd[] = {"gradrnd","'#000000'","'#444400'",NULL};
Offline
Arrgh! So simple, and I should have noticed that myself, but I guess sometimes an outside eye is the best corrective. Problem solved. Thanks to all who helped.
Offline