Reputation:
GCC compiles program using sizeof(long)=8
and Visual Studio has sizeof(long)=4
. How to set sizeof(long) to 8 bytes on Winows x64?
Upvotes: 5
Views: 1479
Reputation: 354
It's a common migration issue:https://msdn.microsoft.com/en-us/library/3b2e7499.aspx. As said before, the spec doesn't say specifically what size a long is and done platforms will be 4 and sone 8.
Upvotes: 0
Reputation: 117926
The actual size of long
isn't specified to be an exact number of bytes, only the range of values that it must be able to represent. You could however use fixed width integers
std::int64_t
This, along with other fixed width integer types, are available in <cstdint>
Upvotes: 6