Difficulty: Easy
Correct Answer: Correct
Explanation:
Introduction / Context:
C and C++ use a preprocessor pass that responds to directives beginning with #. Understanding what directives are and how they are interpreted is foundational for reading and maintaining systems code that uses macros and conditional compilation.
Given Data / Assumptions:
Concept / Approach:
A directive is indeed a “message” giving instructions to the preprocessor about how to transform the source before the compiler proper sees it. For example, #define requests macro definitions, #include asks to insert header contents, and #if/#ifdef conditionally include or exclude parts of the program text.
Step-by-Step Solution:
Recognize directives start with # and usually end at the newline (except for line continuations with backslash).Understand each directive’s effect: macros, conditional text, file inclusion, or diagnostics (#error).Note that after preprocessing, the compiler only sees the transformed, expanded translation unit; directive lines themselves are not present.
Verification / Alternative check:
Run the compiler with a “preprocess only” option (e.g., -E in many toolchains) to observe that directives influence output but the directives themselves disappear (except those like #line inserted for bookkeeping).
Why Other Options Are Wrong:
“Incorrect” would deny the established role of directives; “Only true for #pragma” is too narrow; “True only in C++” ignores that C also uses a preprocessor; “Ambiguous” is not accurate—standards clearly define directive behavior.
Common Pitfalls:
Confusing directives with runtime instructions; believing the preprocessor performs type checking (it does not); thinking directives persist in compiled objects—they do not.
Final Answer:
Correct
Discussion & Comments