A
A
Alexander2019-10-24 17:34:04
C++ / C#
Alexander, 2019-10-24 17:34:04

Why does an empty C program take up 6 kilobytes?

The C language was designed to be closely comparable to machine instructions . Some argue that programming in it is almost as efficient as programming in assembler. I'm new to this language and decided to do a little experiment to see how long an empty program with the following code would take:

int main () {
    return 0;
}

The gcc 4.4.7 compiler on Red Hat 6.7 produces a 6307 byte binary.
As far as I understand, this is much more than similar instructions in assembler take.
Question: what does the remaining space do and can it be configured somehow?
Is the situation similar on all platforms and compilers? How is it solved, for example, on microcontrollers, where there is less memory?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexander Ananiev, 2019-10-24
@SaNNy32

Disassemble and see what's inside the program :)

D
doublench21, 2019-10-24
@doublench21

And you apparently forgot about libraries (C runtime)?
Read at your leisure:
https://stackoverflow.com/questions/1315926/gcc-em...
www.muppetlabs.com/~breadbox/software/tiny/teensy.html

C
CityCat4, 2019-10-24
@CityCat4

Ok google
ELF binary file

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question