Size of 'long integer' data type (C++) on various architectures and OS

Published:11/03/2008   Last Updated:12/26/2018

The size of a "long" integer varies between architectures and operating systems.

The Intel® Compiler is compatible and inter-operable with Microsoft* Visual C++ on Windows* and with gcc* on Linux* and Mac OS X*. Consequently, the sizes of fundamental types are the same as for these compilers. The size of a “long” integer in particular depends on the operating system and the targeted architecture as follows:

OS Architecture Size of "long" type
Windows IA-32 4 bytes
  Intel® 64 4 bytes
Linux IA-32  4 bytes
  Intel® 64 8 bytes
mac OS Intel® 64 8 bytes


Consequently, when programs which use "long" integer data type are ported from IA-32 Linux to Intel® 64 Linux, or from Intel® 64 Windows to Intel® 64 Linux, the behavior might change. (Note that the size of pointers is expected to change between IA-32 and Intel® 64).

In addition, the size of a "long double" also varies by operating system.

On Windows*, the size is 8 bytes by default. On Linux or Mac OS X, 10 bytes are used for the representation of a long double, although the allocated size may be larger (12 bytes on IA-32 Linux; 16 bytes elsewhere).

Suggestion:   If it is important to you for integer types to have the same size on all Intel platforms, then consider replacing "long" by either "int" or "long long". The size of the "int" integer type is 4 bytes and the size of the "long long" integer type is 8 bytes for all the above combinations of operating system and architecture.

On Windows, the representation of "long double" may be increased to 10 bytes by use of the command line switch /Qlong-double. The corresponding memory allocation is 16 bytes.

Product and Performance Information


Intel's compilers may or may not optimize to the same degree for non-Intel microprocessors for optimizations that are not unique to Intel microprocessors. These optimizations include SSE2, SSE3, and SSSE3 instruction sets and other optimizations. Intel does not guarantee the availability, functionality, or effectiveness of any optimization on microprocessors not manufactured by Intel. Microprocessor-dependent optimizations in this product are intended for use with Intel microprocessors. Certain optimizations not specific to Intel microarchitecture are reserved for Intel microprocessors. Please refer to the applicable product User and Reference Guides for more information regarding the specific instruction sets covered by this notice.

Notice revision #20110804