I have a simple header file where I forward-declare all classes in a namespace, eg.
#ifndef TEST_FWD_HPP
#define TEST_FWD_HPP
namespace a {
namespace b {
class A;
class B;
}
}
#endif
Should this file be guarded against multiple includes (#ifndef …) ? Does this make sense for forward declarations only?
It’s usually good practice to protect header files like this. It isn’t necessary in most cases where the file is only included once, but when a project gets complex, and header files are included in other header files it can help keep you sane.
If you only have forward definitions and function prototypes in it, then it usually isn’t necessary, but as header files tend to acrete stuff over time, it’s often worth doing as a matter of course.