Why in Turbo C the compiler sizeof (int) is 2 bytes, while in gcc Linux the compiler is 4 bytes?

Why is Turbo C compiler sizeof(int)

2 bytes and gcc Linux compiler 4 bytes?

+3


source to share


3 answers


sizeof(int)

not constant across all platforms.

It varies from system to system.



PS: Only the sizeof object, which is constant across all platforms, sizeof(char)

+7


source


sizeof(int)

varies from machine to machine (and sometimes from compiler to compiler).



Usually sizeof(int)

represents the "natural" word width of the processor. But if your compiler runs like an x86 program on an x64 machine, even that assumption breaks down.

0


source


The MSDOS instructions contain the codes 16 bit | 2 Bytes

16 bit | 2 Bytes

.
So the maximum integer values ​​will be 16bit

whole numbers.

What I have analyzed so far:

The keyword int

differs from compiler to compiler. Turbo C is a 16 bit

compiler, so it compiles code to 16 bit

machine code for the processor!

As we all know, the compiler converts code to machine code in order to work.
The same is true for GCC .

The computers we use today are 32/64

bits.


The compiler must support the architecture for any application to work.

  • GCC is a 32/64 bit

    compiler. So it sizeof(int)

    is 4 Bytes

    .
  • Turbo C is a 16bit

    compiler. So it sizeof(int)

    is 2 Bytes

    .
0


source







All Articles