Thinking in C and *nix (CSC 295/282 2014S) : EBoards

CSC295 2014S, Class 05: Compilation, Macros, and the C Preprocessor


Overview

Preliminaries

Admin

A C program ecosystem

Steps in compilation

Suppose I have a call to foo() in main.c

The linker figures out where all the instructions go (and what instructions you need) and replaces the _foo with the address.

Including files

#include <stdio.h>
#include "foo.h"

The angle brackets say "It's an installed header file" The lack of angle brackets say "It's a relative path"

Where does it find the stdio.h?

Detour: Why we have included files

Macros

CPP conditionals

Detour: Standard header file format

Command-line flags

Hack: Generic data types

See examples/generic

Copyright (c) 2013-14 Samuel A. Rebelsky.

Creative Commons License

This work is licensed under a Creative Commons Attribution 3.0 Unported License. To view a copy of this license, visit http://creativecommons.org/licenses/by/3.0/ or send a letter to Creative Commons, 543 Howard Street, 5th Floor, San Francisco, California, 94105, USA.