I'm making a 16bit checksum of all words in a memory space from 0 to 0x0020000 with:
uint16_t checksum = 0;
for (uint16_t * word_val = 0; word_val < 0x0020000ul; word_val++)
{
checksum += *word_val;
}
I receive the warning "comparison between pointer and integer". How can I make this warning go away?
word_val
is a pointer, 0x0020000ul
is an integer, and comparing them leads to a warning.
To prevent this warning, just cast the integer constant to a uint16_t pointer, in order to compare datas of the same type :
uint16_t checksum = 0;
for (uint16_t * word_val = 0; word_val < (uint16_t *)0x0020000ul; word_val++)
{
checksum += *word_val;
}