Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is Compatible "int" type in both 32Bit & 64Bit windows in C++?

What is the compatible "int" datatype in C++ that can resize itself to 4 bytes on 32bit & 8 bytes on 64bit windows?

Although INT_PTR works fine but it reduces the readability as well as its description tells us to use it for pointer arithmetic.

Thanks

like image 219
Azher Iqbal Avatar asked Jul 23 '09 07:07

Azher Iqbal


2 Answers

If you're looking for something standard, you're out of luck. The standard does not specify the size of any of the built-in datatypes.

Note, that INT_PTR does not imply pointer arithmetic. I means that the type will have the same size as void *, which is exactly what you want. It won't work on all platforms though (I'm pretty sure it's Windows specific).

like image 60
avakar Avatar answered Sep 22 '22 10:09

avakar


under Visual Studio you are also offered __int3264 which does much the same as INT_PTR ...

like image 40
Goz Avatar answered Sep 22 '22 10:09

Goz