Neranja
<Bronze Donator>
- 2,659
- 4,282
Use some structs then!
I'm not really arguing that #defines can be useful, I just don't like the overall concept.
Those types of #define statements can almost always be replaced by enum statements, which would be statically resolved just like #define statements by the compiler.
By now it is more convention than necessity, but it stems from the time when the C preprocessor was a different program than the compiler itself, and you would cram all those static definitions as #defines into it to not fill up the compiler tables - as memory was a concern back in the day.
It's looked up disfavorably because people got really creative, like implementing whole functions. Which, in turn, was made redundant by both inline functions and automatic loop unrolling in modern compilers. But people learn programming by looking and understanding code of other programmers, which is naturally older and uses those old conventions. And so they pick up some bad habits here and there.
- 1