Mail Archives: djgpp/1998/06/04/19:30:51
In comp.os.msdos.djgpp, article <357488F9 DOT 6054 AT cs DOT com>, John M. Aldrich
(fighteer AT cs DOT com) wrote:
> Warnings are not something trivial to be ignored; any programmer that
> doesn't take full advantage of a compiler's ability to tell him/her
> what's wrong with a program is (IMHO) either ignorant or foolish.
> Ignorance by itself, of course, is not a crime, but there are a
> tremendous number of resources around here devoted to removing it as an
> obstacle. :-)
I'm foolish:
gcc death.c -o death.exe -ljgmod -lalleg -Wall
death.c: in function 'draw_sidebar_stuff':
death.c:6377: warning: array subscript has type 'char'
death.c:6378: warning: array subscript has type 'char'
death.c:6379: warning: array subscript has type 'char'
The offending lines look like this:
textout (active_page, font, level[level_number][message_id].message1,
702, 520, 50);
The level struct looks like this:
struct level_struct
{
unsigned char action_directive;
short action_parameter;
short x_pos;
short y_pos;
char message1[12]; //
char message2[12]; // Yes, I know this is very inefficient...
char message3[12]; //
};
struct level_struct level [51][700];
// 51 levels, max 700 actions per level
And the bit that stores the necessary data:
strcpy (level[n][21].message1, "Collect\0");
strcpy (level[n][21].message2, "the bonus!\0");
strcpy (level[n][21].message3, "\0");
(where n is the level number)
I was never that great with strings. It works, though. How do I get rid
of the warnings?
Btw, there are more to come...
- Raw text -