One method I use is to build a more complex macro name that has a practically zero chance of colliding with other names. This could be built from the following components:
- Project name
- Namespace name
- File name
- Random number or GUID
Example:
#if !defined MYPROJECT_FOO_HPP_9E72F091C4A833D7MYPROJECT_MYNAMESPACE_FOO_HPP_9E72F091C4A833D7 #define ... Overkill? Yes. Easy to do? Yes. Has such an infinitesimally small chance of a collision that I can write and forget about it? Yes.