Week 12 Flashcards
What does the c preprocessor do?
Makes changes to your program before code generation begins
What are the typical uses of a c preprocessor?
Including other files like .h files
Defining constants
Defining macros
Selectively include or exclude some parts of a program
Give additional details to the compiler
What do all preprocessor commands begin with?
#
What does #include do?
Include the contents of one file directly into another file
What does #define symbol value do?
Replace all occurences of symbol with the value
What does #define do?
Can be used to make macros with parameters
The don’t fully behave like function calls
Is it a good practice to hae parameters in parantheses?
Yes, it helps to make sure we get the result we expected.
What does FILE do?
the name of the file being compiled
What is LINE?
The line number where symbol was found.
What is DATE and TIME
indicates when the compilation happened
What is FILE and LINE
Would most typically be used in other macros where you dn’t know immediately where the macro is being used.
What do #if, #else, #endif do?
LEts you use an expression to determine what to include in a compilation
Exclude temporary code with #if 0 …#endif
Include OS-specific code based on the expression
What is the shorthand for #if defined(X)…#endif
Becomes #ifdef X….#endif
What is the shorthand for #if_defined(x)…#endif
Becomes #ifndef X ….#endif
How are compiler specific commands defined?
by #pragma statements