LEC20081030 - Introduction to Computer Programming October...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Introduction to Computer Programming October 30, 2008 CSC180 Fall 2008, University of Toronto The C preprocessor The C preprocessor processes C code before compilation. It can perform macro substitution, conditional compilation, and inclusion of files. The C preprocessor is controlled by the preprocessor directive , which begins with # . A line with only one non-whitespace character, # , is called a null directive ; a null directive has no effect. Use gcc -E a.c to see the output after preprocessing a.c . CSC180 Fall 2008, University of Toronto 1 Macro definition Given this macro definition, #define PST 0.08 , subsequent occurrences of PST will be replaced by 0.08 after preprocessing. PST may appear anywhere and has effect that lasts until the end of the source file. Macro substitution performs textual replacement. The C compiler does not understand macros and never sees macros: macros, along with preprocessor directives, disappear after preprocessing. Example: CSC180 Fall 2008, University of Toronto 2 #define BASE #define OFFSET 10 #define LINE (BASE + OFFSET) /* use previous definitions */ #define forever for(;;) Macro names are not recognized within identifiers, comments, string literals or character constants....
View Full Document

This note was uploaded on 01/10/2011 for the course CSC 180 taught by Professor Na during the Fall '01 term at University of Toronto- Toronto.

Page1 / 15

LEC20081030 - Introduction to Computer Programming October...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online