I am rewriting a function and I noticed one particular variable is never reassigned after initialization. Is there any reason NOT to simply convert this variable to a macro? Is a macro ALWAYS preferable in this case?
Thanks!
I am rewriting a function and I noticed one particular variable is never reassigned after initialization. Is there any reason NOT to simply convert this variable to a macro? Is a macro ALWAYS preferable in this case?
Thanks!
A macro is basically never preferable compared to a variable, since a variable which doesn't change its value can be declared as const
and it will likely be optimized away in any case.
const int CONST_VALUE = 1234;
is safer and clearly expresses the meaning more than a macro.