Why do people consider macros in c to be bad practice?
- User
Why do people consider macros in c to be bad practice?
Assistant
There are a few common reasons why macros are sometimes considered bad practice in C:
-
Macros don't respect scope. Macros simply do textual replacement, so anything defined as a macro can affect code in any file that includes the header defining the macro. This can lead to unintended consequences and name collisions.
-
Macros don't respect types. Macros operate at the text level before code is compiled, so they don't perform type checking like normal functions do. This can lead to bugs if types are mixed incorrectly.
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.