size of long integer type on different architecture and OS

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           arch           size
Windows       IA-32        4 bytes
Windows       Intel 64     4 bytes
Windows       IA-64        4 bytes
Linux            IA-32        4 bytes
Linux            Intel 64     8 bytes
Linux            IA-64        8 bytes
Mac OS X      IA-32        4 bytes
Mac OS X      Intel 64     8 bytes 

Consequently, when some programs that use "long" 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.
For more complete information about compiler optimizations, see our Optimization Notice.