---
title: The GNU C Preprocessor Internals
framework: developertools
role: article
path: apple-archive/documentation/DeveloperTools/gcc-4.2.1/cppinternals
---

# The GNU C Preprocessor Internals

The GNU C Preprocessor Internals

## Table of Contents

- The GNU C Preprocessor Internals 1 Cpplib&mdash;the GNU C Preprocessor Conventions The Lexer [Overview](Lexer.html#Lexer) [Lexing a token](Lexer.html#Lexer) [Lexing a line](Lexer.html#Lexer)

Hash Nodes

Macro Expansion Algorithm

- [Internal representation of macros](Macro-Expansion.html#Macro-Expansion) [Macro expansion overview](Macro-Expansion.html#Macro-Expansion) [Scanning the replacement list for macros to expand](Macro-Expansion.html#Macro-Expansion) [Looking for a function-like macro's opening parenthesis](Macro-Expansion.html#Macro-Expansion) [Marking tokens ineligible for future expansion](Macro-Expansion.html#Macro-Expansion)

Token Spacing

Line numbering

- [Just which line number anyway?](Line-Numbering.html#Line-Numbering) [Representation of line numbers](Line-Numbering.html#Line-Numbering)

The Multiple-Include Optimization

File Handling

Concept Index

Next: [Conventions](Conventions.html#Conventions), Up: [(dir)](../index.html#dir)

## 1 Cpplib&mdash;the GNU C Preprocessor

The GNU C preprocessor is implemented as a library, cpplib , so it can be easily shared between a stand-alone preprocessor, and a preprocessor integrated with the C, C++ and Objective-C front ends. It is also available for use by other programs, though this is not recommended as its exposed interface has not yet reached a point of reasonable stability.

The library has been written to be re-entrant, so that it can be used to preprocess many files simultaneously if necessary. It has also been written with the preprocessing token as the fundamental unit; the preprocessor in previous versions of GCC would operate on text strings as the fundamental unit.

This brief manual documents the internals of cpplib, and explains some of the tricky issues. It is intended that, along with the comments in the source code, a reasonably competent C programmer should be able to figure out what the code is doing, and why things have been implemented the way they have.
