E
Eugene Rice
I'm writing C code for an Atmel AVR micro controller. Because RAM space is extremely limited (about 500 bytes) I use char variables wherever I can. For example I use chars as array indices in dozens of places:
char arr[3];
char x,y,z;
for (x=0; x<3; x++) {
arr[x] = ...; // gcc gives warning here
// more code
}
The gcc AVR compiler I use generates a warning for each char array index as above, leading to warning message clutter on the compiler output. Normally I like clean compiles, but I think that my char index usage is neither illegal nor indicative of an error.
What do people think? Is the gcc warning in any way useful in diagnosing a possible error? Am I right that my usage is completely legal?
I might be able to quiet down gcc by putting in int casts, but that would clutter the code, and to me casts say to the reader "yes I know I'm doing something questionable, but trust me I've analyzed the situation and the code is correct", yet as I said I don't think my char indices are questionable.
Thanks,
Geno
char arr[3];
char x,y,z;
for (x=0; x<3; x++) {
arr[x] = ...; // gcc gives warning here
// more code
}
The gcc AVR compiler I use generates a warning for each char array index as above, leading to warning message clutter on the compiler output. Normally I like clean compiles, but I think that my char index usage is neither illegal nor indicative of an error.
What do people think? Is the gcc warning in any way useful in diagnosing a possible error? Am I right that my usage is completely legal?
I might be able to quiet down gcc by putting in int casts, but that would clutter the code, and to me casts say to the reader "yes I know I'm doing something questionable, but trust me I've analyzed the situation and the code is correct", yet as I said I don't think my char indices are questionable.
Thanks,
Geno