Difficulty: Easy
Correct Answer: a macro (preprocessor symbol) has been defined
Explanation:
Introduction / Context:The C/C++ preprocessor runs before compilation and handles directives like #define, #include, and conditional compilation. #ifndef is commonly used in header guards to ensure a file is processed only once even if included multiple times. Understanding what #ifndef actually tests prevents subtle multiple-definition errors.
Given Data / Assumptions:
Concept / Approach:
Step-by-Step Solution:
Identify the entity #ifndef operates on → macros/preprocessor symbols.Relate to header guards that prevent multiple inclusion.Therefore, #ifndef tests whether a macro has been defined; if not, the guarded code is included.Verification / Alternative check:
Compile a project with and without a macro defined via -DMYFLAG; #ifndef MYFLAG will include code only when MYFLAG is not set.Why Other Options Are Wrong:
Common Pitfalls:
Final Answer:
a macro (preprocessor symbol) has been defined
Discussion & Comments