C compilation!?

Brandixitor
3 min readSep 16, 2020

C!? What is c!?

The history of C language is interesting to know. Here we are going to discuss a brief history of the c language.

C programming language was developed in 1972 by Dennis Ritchie at bell laboratories of AT&T (American Telephone & Telegraph), located in the U.S.A.

Dennis Ritchie is known as the founder of the c language.

It was developed to overcome the problems of previous languages such as B, BCPL, etc.

Initially, C language was developed to be used in UNIX operating system. It inherits many features of previous languages such as B and BCPL.

Process of a c file compilation

.c?

A .c file is a source code file for a C program. It may include an entire program’s source code, or may be one of many source files referenced within a programming project. … It is used for creating many of today’s software programs and may be stored in C.

.o?

A .o is a file extension for an object file used with Unix and Linux systems. .o stands for object. .o files contain C source code to be compiled into an application. .o files can be opened by GCC (GNU C Compiler) on Unix and Linux systems, and Microsoft Visual Studio on Windows systems.

.s?

.s files are source code files written in assembly. Assembly is an extremely low-level form of programming. The files contain assembly instructions to the processor in sequential order and are typically compiled based on a selected architecture.

How a C program is compiled and what are the steps of compilation?

Binary codes (machine codes)

C is a compiled language. Its source code is written using any editor of a programmer’s choice in the form of a text file, then it has to be compiled into machine code.

C source files are by convention named with .c extension and we use the command “gcc” to compile C source files. (GCC stands for GNU Compiler Collection and it is a compiler system produced by the GNU Project.)

Preprocessing:

Preprocessing is the first step. The preprocessor obeys commands that begin with # (known as directives) by:

  • removing comments
  • expanding macros
  • expanding included files

If you included a header file such as #include <stdio.h>, it will look for the stdio.h file and copy the header file into the source code file.

The preprocessor also generates macro code and replaces symbolic constants defined using #define with their values.

Compiling:

Compiling is the second step. It takes the output of the preprocessor and generates assembly language, an intermediate human readable language, specific to the target processor.

Assembley:

Assembly is the third step of compilation. The assembler will convert the assembly code into pure binary code or machine code (zeros and ones). This code is also known as object code.

Linking:

Linking is the final step of compilation. The linker merges all the object code from multiple modules into a single one. If we are using a function from libraries, linker will link our code with that library function code.

In static linking, the linker makes a copy of all used library functions to the executable file. In dynamic linking, the code is not copied, it is done by just placing the name of the library in the binary file.

--

--

Brandixitor

Software Engineering student at Holberton School, Tunisia. 💻 Video Games and AR/VR developer. 🎮