Prefer the compiler-understood constructs by default. For a typed constant, static const or an enum gives you a type, respects scope, is visible to the debugger, and (for const on embedded) can live in flash, a #define is untyped text with file-wide reach and no debug symbol. For a small computation, a static inline function is type-checked, evaluates each argument exactly once (no double-evaluation hazard), and modern compilers inline it just like a macro. Reserve macros for things the language constructs genuinely can't do: type-generic code where one macro must work across int/float/pointers, array dimensions or #if conditions that need a preprocessor constant, capturing __FILE__/__LINE__, conditional compilation, and token operations with #/##. The principle: use the preprocessor only for jobs that require the preprocessor.
C Programming · Interview question
When should you use a macro versus a const or inline function?
A strong answer
What a weak answer sounds like
You know the answer. Do you know what gets you dinged?
Pro breaks down the answer most candidates actually give to this question — and the specific reason an interviewer marks it down. It’s the difference between sounding correct and sounding senior, on all 472 questions.
From the lesson
The Preprocessor
Text substitution before the compiler ever runs: object and function macros, header guards, conditional compilation, and why a naive MAX macro evaluates its argument twice.