Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

412
Views
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 answers
Answer question

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 Report

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!