Page 2 of 2

Posted: Sun Jan 14, 2007 9:33 am
by JAAman
I'm pretty sure even Microsofts x86_64 compiler doesn't do this. It's very common to have long long always 64-bit and the long type as whatever the native type of the processor is. They would both be 64-bit then, which this line forbids.
iirc, in the MS x86-64 compiler, long is 32bits (not 64)

Posted: Tue Jan 16, 2007 2:23 pm
by Candy
JAAman wrote:
I'm pretty sure even Microsofts x86_64 compiler doesn't do this. It's very common to have long long always 64-bit and the long type as whatever the native type of the processor is. They would both be 64-bit then, which this line forbids.
iirc, in the MS x86-64 compiler, long is 32bits (not 64)
Hm... ok, it would still imply (and make you think) that GCC isn't compliant with C/C++, where it really is.

Just a small note on the original topic, you can add them portably by casting them to intptr_t and adding them. There's just a small catch, why add two pointers? In all cases you have an object at a given location and an index into the object, you never add the location of one object to the location of another.

You can have slightly more complex ones, where A=B+C-D or such, but in that case C-D would be a ptrdiff_t and you can logically add a ptrdiff_t to an intptr_t to get another intptr_t.

Why do you want to add two pointers?