What is the correct strategy to limit the scope of #define labels and avoid unwarranted token collision?
In the following configuration:
What is the correct strategy to limit the scope of #define and avoid unwarrented token collisions.
Some simple rules:
#include guards only. I don't go this far, but it is a good idea to keep preprocessor symbols down to a minimum.
const static variables rather than named floating point constants.
const UINT ZERO = 0; // Programmer not aware of what's inside Utility.h
First off, if the programmer isn't away of what's inside Utility.h, why did the programmer use that #include statement? Obviously that UINT came from somewhere ...
Secondly, the programmer is asking for trouble by naming a variable ZERO. Leave those all cap names for preprocessor symbols. If you follow the rules, you don't have to know what's inside Utility.h. Simply assume that Utility.h follows the rules. Make that variable's name zero.