C macro naming conventions – must macros always be written in uppercase letters?\nJudge the correctness of this style-related statement.

Difficulty: Easy

Correct Answer: Incorrect

Explanation:


Introduction / Context:
C programmers often write macro names in uppercase, leading to the misconception that uppercase is mandatory. This question clarifies the difference between language rules and community conventions.



Given Data / Assumptions:

  • The claim: “A macro must always be defined in capital letters.”
  • Macros may be object-like or function-like.


Concept / Approach:
The C standard imposes no case requirement on identifiers for macros. Uppercase naming is a widespread convention to visually distinguish macros from variables and functions, highlighting that they are substituted textually and may have side effects or unusual precedence. Style guides recommend uppercase, but it is not required.



Step-by-Step Solution:
Recall identifier rules: letters, digits, underscore; case-sensitive.No rule demands uppercase; lowercase macros compile the same.Therefore, the statement is not universally true.



Verification / Alternative check:
Define #define square(x) ((x)*(x)) and observe successful compilation and expansion.



Why Other Options Are Wrong:
Only true for function-like macros — still a convention, not a rule. Required by the C standard — incorrect; there is no such mandate.



Common Pitfalls:
Assuming style conventions are formal rules; forgetting to parenthesize macro parameters and results; trusting macros to provide type checking (they do not).



Final Answer:
Incorrect

More Questions from C Preprocessor

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion