25 Preprocessor

25 Preprocessor - !"!"#$ CMSC 216 Introduction to...

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

View Full Document Right Arrow Icon
!"!"## # CMSC 216 Introduction to Computer Systems Lecture 25 C Preprocessor Jan Plane & Pete Keleher {jplane, keleher}@cs.umd.edu Administrivia • Project 6 – questions? • Practice final exam posted, with answers coming soon • Please do course evaluation, at www.CourseEvalUM.umd.edu CMSC 216 - Wood, Sussman, Herman, Plane 2
Background image of page 1

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

View Full DocumentRight Arrow Icon
!"!"## % T HE P REPROCESSOR Chapter 14, Reek CMSC 216 - Wood, Sussman, Herman, Plane 3 Compiling a program • Source files ( *.c ) compiled into object files ( *.o ) 1. Source file is first preprocessed 2. Preprocessed file is then compiled to assembly 1. scanner/parser 2. type checker 3. code generator 4. optimizer 3. Assembler converts assembly code to object code Object files are converted into an executable Done by the linker, which resolves symbols match function use to its definition global variable declaration and external use CMSC 216 - Wood, Sussman, Herman, Plane 4
Background image of page 2
!"!"## Preprocessor predefined symbols __FILE__ : a string, the filename in which the symbol is found __LINE__ : an integer, the line on which the symbol is found __DATE__ : a string, date of compilation __TIME__ : a string, time of compilation __STDC__ : 1 or undefined, whether or not compiler is ANSI-compliant • Note that each is preceded and followed by two underscores • Examples of their values are available in table 14.1 (pg. 383) of Reek CMSC 216 - Wood, Sussman, Herman, Plane 5 The #define directive • Syntax: #define name lots of text • Substitutes lots of text for name throughout the source file • Most commonly used for constants • By convention, we use all capital letters for our constants - makes it easier for humans to recognize them CMSC 216 - Wood, Sussman, Herman, Plane 6
Background image of page 3

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

View Full DocumentRight Arrow Icon
!"!"## ' Macros #define can also be used to define macros, where parameters are substituted as well as straight text substitution • Syntax: #define name(parameter-list) text
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 11

25 Preprocessor - !"!"#$ CMSC 216 Introduction to...

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