I know it makes little difference to a project but, assuming you use #defined header guards for your C++ code, what format do you use? e.g. assuming a header called foo.hpp:
#ifndef __FOO_HPP__ ... #ifndef INCLUDED_FOO_HPP ... #ifndef SOME_OTHER_FORMAT
I’m sold on the idea of upper-case #defines but cannot settle on a format for these guards.
I always included the namespace or relative path in the include guard, because only the header name alone has proven to be dangerous.
For example, you have some large project with the two files somewhere in your code
So if you use a consistent naming schema for your include guards you might end up with having
_MISC_HPP__defined in both files (very funny to find such errors).So I settled with
These names are rather long, but compared with the pain of double definitions it is worth it.
Another option, if you don’t need compiler/platform independence you might look for some #pragma once stuff.