Understanding the GCC compiler

The official GCC logo

The GCC compiler ( gcc stands for GNU Compiler Collection ), is one of the most used compiler systems in the world and played an important role in the growth of free software basically for being under the GNU General Public License (GNU GPL).

What is a compiler?

The compiler is a peace of software that translates computer code written in one programming language into another language.

How is GCC doing it?

* Preprocessing:

The compiler runs on each C source file before actual compilation, it

1- Removes Comments

2 -Expands Macros

3- Expands of the files included to the source code

The output will be a processed .c file sent to the standard output.

( ps: Input files that don’t require preprocessing are ignored.)

The -E flag stops “gcc” after the preprocessing stage; and before runing the compiler proper.

the preprocessed file of a simple printf(“Hello world!”) programm

* Compilation:

The compiler “translates” the preprocessed .c file from the “C” language to the Assembly code language (symbolic machine code),

The -S flag stops “gcc” after the stage of compilation proper, and the output will be in the form of an assembler code file.

The content of helloworld.s

* Assembly:

The compiler assemble the source files, but do not link and The ultimate output is in the form of an object file (.o) containing object code, that is, machine code.

The -c flag stops “gcc” after the stage of assembling.

* Linking:

The compiler operates the final phase in which all the linking of function calls with their definitions are made.

The final output will be an executable file with 755 permissions.

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Advantages of Hadoop Development

Open Source

The Cloud Resume Challenge: A glimpse to full-stack development

MVC Core Part 4 : Creating your first UI

This article is for anyone looking to become a developer/programmer.

[LeetCode]#806. Number of Lines To Write String

From 1 to 1 Billion: Evolution of a Document Serving System

Kanban Boards, To-Do Lists and More: Which Style is Best for Your Small Business Project Management

Best project management software

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Chebbi Mounir

Chebbi Mounir

More from Medium

Common SSL ERRORS.

Knapsack problem using greedy method

UltraFTP: Finally, a secure, commercially supported Windows 64-bit FTP client

WESTWING INSIGHTS: Women in Tech