Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

413
Visualizações
Why in Turbo C compiler sizeof(int) is 2 bytes and in gcc Linux compiler is 4 byte?

Why in Turbo C compiler sizeof(int) is 2 bytes and in gcc Linux compiler is of 4 bytes?

over 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

sizeof(int) is not a constant across all platforms.

It varies from system to system.

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

over 4 years ago · Santiago Trujillo Relatório

0

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

Usually sizeof(int) represents the "natural" word width of the CPU. But If your compiler runs as x86 program on a x64 machine even this assumption breaks.

over 4 years ago · Santiago Trujillo Relatório

0

In MSDOS instructions codes are 16 bit | 2 Bytes.
So, the maximum integer values would be 16bit integers.

What I've analysed so far:

The keyword int differs from compiler to compiler. Turbo C is a 16 bit compiler so it compiles the code into a 16 bit machine code for the processor!

As we all know, a compiler will convert the code to a machine code in order to work.
Same applies for GCC.

The computers we use today is either 32/64 bit.


A compiler should support the architecture to make any applications work.

  • GCC is 32/64 bit compiler. So, sizeof(int) is 4 Bytes.
  • Turbo C is 16bit compiler. So, sizeof(int) is 2 Bytes.
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda