Microbit Architecture Flashcards

(21 cards)

1
Q

What is the C Preprocessor (CPP)?

A

A tool used automatically by the C compiler to transform a program before compilation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Why is the C Preprocessor called a macro processor?

A

Because it allows you to define macros

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are the primary capabilities of the C preprocessing language?

A
  • Macro expansion
  • Conditional compilation
  • Diagnostics
  • Inclusion of header files
  • Control over the compiler
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is tokenization in C preprocessing?

A

The process of splitting C code into tokens such as identifiers

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What happens during the initial processing phase of preprocessing?

A
  1. Input file is read and broken into lines
  2. Continued lines merged with backslash \
  3. Comments replaced with single spaces
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How are block and line comments handled during C preprocessing?

A

Both block (/*...*/) and line (//...) comments are replaced with single spaces.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How is a macro defined in C?

A

With the #define directive

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How do you undefine a macro in C?

A

Using the #undef directive followed by the macro’s name.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is a function-like macro?

A

A macro that looks like a function call and appends a pair of parentheses immediately after its name.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is stringification in C macros?

A

A technique where a macro parameter is converted into a string constant.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What are predefined macros?

A

Several object-like macros that are built-in and available without needing to redefine them.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is conditional compilation used for?

A
  • Adapting code to different machines or OS environments
  • Compiling the same source file into multiple programs
  • Excluding code by using always-false conditions
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the purpose of the #if directive?

A

To test the value of an arithmetic expression of integral type using arithmetic or logical operators.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How are #elif and #else used?

A
  • #elif tests alternative conditions if the main one fails
  • #else handles the case when all previous conditions fail
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What does #endif do?

A

It closes an #if

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is the purpose of #ifdef and #ifndef?

A
  • #ifdef checks if an identifier has been defined
  • #ifndef checks if an identifier has not been defined
17
Q

What does the #include directive do?

A

It includes header files into the program.

18
Q

What is the difference between #include <file.h> and #include ""file.h""?

A
  • #include <file.h> searches in the standard system directories
  • #include "file.h" searches the current project directory first, then system directories
19
Q

What is double inclusion in C compilation?

A

When a header file is included twice

20
Q

How is double inclusion prevented?

A

By enclosing the header file’s content within a conditional directive.

21
Q

What is a computed #include?

A

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.