Microbit Architecture Flashcards
(21 cards)
What is the C Preprocessor (CPP)?
A tool used automatically by the C compiler to transform a program before compilation
Why is the C Preprocessor called a macro processor?
Because it allows you to define macros
What are the primary capabilities of the C preprocessing language?
- Macro expansion
- Conditional compilation
- Diagnostics
- Inclusion of header files
- Control over the compiler
What is tokenization in C preprocessing?
The process of splitting C code into tokens such as identifiers
What happens during the initial processing phase of preprocessing?
- Input file is read and broken into lines
- Continued lines merged with backslash
\
- Comments replaced with single spaces
How are block and line comments handled during C preprocessing?
Both block (/*...*/
) and line (//...
) comments are replaced with single spaces.
How is a macro defined in C?
With the #define
directive
How do you undefine a macro in C?
Using the #undef
directive followed by the macro’s name.
What is a function-like macro?
A macro that looks like a function call and appends a pair of parentheses immediately after its name.
What is stringification in C macros?
A technique where a macro parameter is converted into a string constant.
What are predefined macros?
Several object-like macros that are built-in and available without needing to redefine them.
What is conditional compilation used for?
- Adapting code to different machines or OS environments
- Compiling the same source file into multiple programs
- Excluding code by using always-false conditions
What is the purpose of the #if
directive?
To test the value of an arithmetic expression of integral type using arithmetic or logical operators.
How are #elif
and #else
used?
-
#elif
tests alternative conditions if the main one fails -
#else
handles the case when all previous conditions fail
What does #endif
do?
It closes an #if
What is the purpose of #ifdef
and #ifndef
?
-
#ifdef
checks if an identifier has been defined -
#ifndef
checks if an identifier has not been defined
What does the #include
directive do?
It includes header files into the program.
What is the difference between #include <file.h>
and #include ""file.h""
?
-
#include <file.h>
searches in the standard system directories -
#include "file.h"
searches the current project directory first, then system directories
What is double inclusion in C compilation?
When a header file is included twice
How is double inclusion prevented?
By enclosing the header file’s content within a conditional directive.
What is a computed #include
?
A technique where the need for a header file can be specified externally as a compiler option instead of using conditional inclusion within the file.