user2440074
user2440074

Reputation:

Is there any way to set C++ long type size with 8 bytes (x64)?

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

Answers (2)

Dan
Dan

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

Cory Kramer
Cory Kramer

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

Related Questions