What's the correct type to use for pointer subtraction on x64?

Posted by Cheeso on Stack Overflow See other posts from Stack Overflow or by Cheeso
Published on 2010-05-29T20:48:23Z Indexed on 2010/05/29 20:52 UTC
Read the original article Hit count: 248

Filed under:
|

I'm just starting out with x64 compilation.

I have a couple of char*'s, and I'm subtracting them. With a 32-bit compile, this works:

char * p1 = ....
char * p3 = ... 
int delta = p3 - p1;

But if I compile for x64 I get a warning:

 warning C4244: 'initializing' : conversion from '__int64' to 'int', 
      possible loss of data

What is the correct type to use, to represent a difference between two pointers, that works in both x86 and x64 compiles?

© Stack Overflow or respective owner

Related posts about x64

Related posts about msvc