How are C++ include guards typically named? I tend to see this a lot:
#ifndef FOO_H
#define FOO_H
// ...
#endif
However, I don't think that's very intuitive. Without seeing the file name it's difficult to tell what FOO_H
is there for and what its name refers to.
What's considered best practice?
Replace
FOO_H
withFOO_H_INCLUDED
and it's clearer.From my own experience, the convention is to name the inclusion guards after the header file containing them with the exception that the name is all in caps and the period is replaced with an underscore.
So
test.h
becomesTEST_H
.Real life examples of this include Qt Creator, which follows this convention when auto-generating class header files.
I usually look what time it is and just append that to the end of it, i.e.
FOO_H_248
, it's an extra precaution, and you'll never have to remember it anyway, so you don't need to worry about the fact that it's cryptic.