Chapter 7 Preprocessor Directives

This chapter describes preprocessor directives—commands that control the QuickC compiler. It explains how to insert the contents of one source file into another file, how to do text substitutions throughout a file, and how to compile different parts of a file in different situations.

A “preprocessor directive” is a command to the QuickC compiler. Although they appear in the same source file as executable statements, preprocessor directives aren't statements in the formal sense. Unlike executable statements, they are not translated into machine code. Instead, they tell the compiler itself to take some action while it translates your source program. For instance, an #include directive tells QuickC to insert another file into the source file.

The term “preprocessor” refers to the time when these commands are carried out. Like most language compilers, QuickC translates your source program in several phases, the first of which is called the “preprocessor phase.” QuickC first “preprocesses” all the directives in your source program, then processes the program's executable statements.

All preprocessor directives begin with a number sign (#), which must be the first nonblank character in the line on which it appears. Since directives aren't statements, they don't end with semicolons. You can't put other statements or directives on the same line with a preprocessor directive, except for a comment, which must appear to the right of the directive.

Because the compiler reads your source file sequentially, line by line, the position of directives is important. A preprocessor directive only affects statements that follow it in the source file.