Greetings. First post to this forum.
Trying to compile this code on my Linux box using gcc 3.3.3. I get the following warning:
[tt]
gcc -Wall -O -ggdb -Dunix -DNOCRYPT bitsys.c -c -o obj/bitsys.o
bitsys.c: In function `str_flag_string':
bitsys.c:80: warning: operation on `toggle' may be undefined
[/tt]
The code in question is:
[tt]
75 char *str_flag_string(const struct flag_type *flag_table, FLAG * bits)
78 static int toggle;
79
80 toggle = (++toggle) % 10;
[/tt]
I'm really not sure how to fix the warning. Initializing it in the function will munge the static property right? The code compiles, but no warnings is a requirement. Any advice would be appreciated (slow replies though, I work a lot the first part of the week). By the way, it's some MUD code in case the context matters to anyone. I don't think that's important with this warning though.
----
JBR
Trying to compile this code on my Linux box using gcc 3.3.3. I get the following warning:
[tt]
gcc -Wall -O -ggdb -Dunix -DNOCRYPT bitsys.c -c -o obj/bitsys.o
bitsys.c: In function `str_flag_string':
bitsys.c:80: warning: operation on `toggle' may be undefined
[/tt]
The code in question is:
[tt]
75 char *str_flag_string(const struct flag_type *flag_table, FLAG * bits)
78 static int toggle;
79
80 toggle = (++toggle) % 10;
[/tt]
I'm really not sure how to fix the warning. Initializing it in the function will munge the static property right? The code compiles, but no warnings is a requirement. Any advice would be appreciated (slow replies though, I work a lot the first part of the week). By the way, it's some MUD code in case the context matters to anyone. I don't think that's important with this warning though.
----
JBR