


It removes comments, expands include-files and macros, and processes conditional compilation instructions. Preprocessing is the first pass of any C compilation.The compilation process involves four stages and utilizes different ‘tools’ such as a preprocessor, compiler, assembler, and linker in order to create a final executable. Suppose we want to compile a C program contained in hello.c. Here is a concrete example (drawn heavily from this article, which goes into much greater detail about the memory map in C). Compiling is the process of turning our C program files into an executable. First of all, what even is an executable? An executable is a special type of file that contains machine instructions (ones and zeros), and running this file causes the computer to perform those instructions. What is Compiling?īefore we go into the lab, let’s discuss what it means to compile a program into an executable. Once we move to C++, you’ll work with g++ and clang++, which are the C++ equivalents of these compilers. Throughout this lab, you’ll use gcc to get a feel for the compilation process, but feel free to use the clang compiler throughout the course. There are two main C compilers used today: gcc (the GNU C Compiler) and clang (a new compiler from the LLVM compiler framework that for the most part supports more informative error messages).

In this lab, we’ll dive into the details of how you compile C programs, and how you automate compilation in larger projects that consist of multiple source files. Until now, you haven’t really had to think about how programs are compiled. « Back to the main CS 131 website Lab 2: Compiling C Programs Due February 19, 2020, at 8:00PM
