Re:How to properly use macros in C
by vortico on Sunday December 10, 2017 @03:36PM
(#15893367)
The golden rule of macros is "always read the definition of macros before using." If you know it's a single value you're probably fine `#define MASK 0xf7`, but if it's a function macro or a normal macro that you know is doing more than inserting a literal in your code, it's best to glance at the macro to see what it does. Macros are useful for writing "shorthand C", but C should not be turned into a DSL, so you should think in actual C by converting the "shorthand C" in your head as you read/write it.
[ Parent
| on HN ]
There are no comments on this comment yet.