"If a worker wants to do his job well, he must first sharpen his tools." - Confucius, "The Analects of Confucius. Lu Linggong"
Front page > Programming > Why Isn't 'long' 64 Bits on 64-bit Windows?

Why Isn't 'long' 64 Bits on 64-bit Windows?

Posted on 2025-03-23
Browse:248

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 header, offering platform-specific integer types: int8_t, int16_t, int32_t, int64_t, uintptr_t, intmax_t. Utilizing these types ensures that your application can adapt to different integer sizes.

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 and carefully handling system types can help ensure code portability and avoid potential integer size issues.

Latest tutorial More>

Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.

Copyright© 2022 湘ICP备2022001581号-3