Difficulty: Easy
Correct Answer: Incorrect
Explanation:
Introduction / Context:
This item examines how the C preprocessor works versus normal runtime control flow. Many beginners think calling a macro behaves like calling a function. In reality, macros are handled before compilation as a text-substitution step, and there is no runtime “transfer of control” to a macro body because a macro does not exist in the executable program.
Given Data / Assumptions:
Concept / Approach:
Macros are processed by the preprocessor. The directive #define NAME replacement causes every subsequent token sequence matching NAME to be replaced by replacement before the actual compilation phase. For function-like macros, the tokens between parentheses are substituted into the replacement list. After substitution, the compiler sees only ordinary C code. Therefore, at runtime, the CPU never “jumps into” a macro; it executes the code that was generated after expansion.
Step-by-Step Solution:
Recognize that macro use triggers no runtime mechanism; expansion occurs during preprocessing.After expansion, the compiler treats the resulting tokens as if they were typed in place.Execution time contains no macro entity; hence, no control transfer to a macro can occur.
Verification / Alternative check:
Compare with an inline function. An inline function still has type checking and linkage; a macro does not. Disassembling a program shows there is no call to any “macro symbol”.
Why Other Options Are Wrong:
Correct — wrong because preprocessing is not runtime. Depends on compiler — macro expansion is a language-phase rule, not an optimization choice. Only true for function-like macros at runtime — still false; they expand to tokens before compile.
Common Pitfalls:
Confusing macros with functions, expecting type safety from macros, and assuming they carry runtime overhead. Macros can cause subtle bugs if parentheses are omitted in definitions and arguments.
Final Answer:
Incorrect
Discussion & Comments