views:

35

answers:

2

Is it possible to change the number of bytes a long has in visual studio? Currently when compiling C code sizeof(int) and sizeof(long) are both equal to 4.

+1  A: 
typedef __int64 long;

That kind of nasty things.

BarsMonster
doesn't work. You get error syaing __int64 followed by long is illegal.
Reflux
Mmm, #define long __int64 :-)
BarsMonster
+2  A: 

Since you're using Visual Studio, presumably your target platform (and the libraries you're using) target Windows. The Win64 platform uses an LLP64 model (http://msdn.microsoft.com/en-us/library/aa384083.aspx) where int and long are 32-bits. It would be futile I think to try to make long a 64-bit type in that situation.

Use int64_t (from stdint.h) or long long or similar to get a 64-bit integer type

Michael Burr