Home >Backend Development >C++ >Why Isn't 'long' 64 Bits on 64-bit Windows?
The Bit Size of 'long' in 64-bit Windows
The question arises: why is 'long' not 64 bits on 64-bit machines like Windows? This article delves into the history and implications of integer sizing on different platforms.
History of Integer Sizing
In the Unix world, two major integer size arrangements for 64-bit platforms emerged: ILP64 (int, long, pointers are 64-bit) and LP64 (long, pointers are 64-bit). ILP64 was abandoned in favor of LP64, which became the standard for modern 64-bit Unix systems like macOS X and Linux.
Microsoft's LLP64 Scheme
Microsoft employs LLP64 (long long, pointers are 64-bit) for 64-bit Windows, allowing recompilation of 32-bit software without changes. However, this differs from other 64-bit platforms and requires additional code adjustments to exploit 64-bit capabilities.
Platform-Neutral Integer Types
To approach integer sizing cross-platform, the C99 standard provides the
Considerations for Windows
As Windows uses LLP64, it's crucial to note that 'long' remains 32 bits on 64-bit machines. This necessitates care when utilizing system types, which may deviate from platform-neutral integer types.
Conclusion
Understanding the nuances of integer sizing on different platforms is essential for developing cross-platform software. Utilizing platform-neutral integer types from
The above is the detailed content of Why Isn't 'long' 64 Bits on 64-bit Windows?. For more information, please follow other related articles on the PHP Chinese website!