Re: [AD] warnings when using VC 7 (.net) |
[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]
Evert Glebbeek wrote:
void pointer arithmetic is undefined so using it for address calculation is painful.Ok, fair enough. I assume using a char* isn't really an option either?> Regardless, I *think* using ptrdiff_t instead of unsigned long *should* > fix the problem. (It must be large enough to hold the whole range of > pointer differences, which would be of the order of 2**64 on 64 bit > systems. IIRC, it is defined as (signed) long by DJGPP.) Is it ISO C ?
It's C99 - no clue if it's C89 or not. Here's what's in my copy of the standard:"9 When two pointers are subtracted, both shall point to elements of the same array object, or one past the last element of the array object; the result is the difference of the subscripts of the two array elements. The size of the result is implementation-defined, and its type (a signed integer type) is ptrdiff_t defined in the <stddef.h> header. If the result is not representable in an object of that type, the behavior is undefined. In other words, if the expressions P and Q point to, respectively, the i-th and j-th elements of an array object, the expression (P)-(Q) has the value i-j provided the value fits in an object of type ptrdiff_t. Moreover, if the expression P points either to an element of an array object or one past the last element of an array object, and the expression Q points to the last element of the same array object, the expression ((Q)+1)-(P) has the same
value as ((Q)-(P))+1 and as -((P)-((Q)+1)), and has the value zero if theexpression P points one past the last element of the array object, even though the
expression (Q)+1 does not point to an element of the array object.88)"
Mail converted by MHonArc 2.6.19+ | http://listengine.tuxfamily.org/ |