Warning: pointer of type 'void *' used in subtraction

Posted by idealistikz on Stack Overflow See other posts from Stack Overflow or by idealistikz
Published on 2010-04-26T03:06:55Z Indexed on 2010/04/26 3:13 UTC
Read the original article Hit count: 241

Filed under:

Although it runs correctly, the following results in the aforementioned compiler warning:

return ((item - (my->items))/(my->itemSize));

'item' is a 'void *'; 'my->items' is a 'void *'; 'my->itemSize' is an 'int'

Casting 'item' and 'my->items' as an 'int *' caused the program to run improperly. What is the best way to remove the warning?

© Stack Overflow or respective owner

Related posts about c