Skip to main content
Added namespace.
Source Link
user22815
user22815

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.

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
  • File name
  • Random number or GUID

Example:

#if !defined MYPROJECT_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.

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_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.

Source Link
user22815
user22815

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
  • File name
  • Random number or GUID

Example:

#if !defined MYPROJECT_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.