I have just stumbled upon a project in which the include guards of every header file look like this:
#ifndef A_H
#define A_H
/* Code */
#else
#error "Multiple inclusion of file a.h"
#endif
Is there an actual usecase for having an #error directive there? It looks like it kills the purpose of having an include guard at all.
The code compiles and works perfectly when removing the #else-#error directives.
Possibly. But it's not typical.
Indeed. Having the error directive makes the include guard redundant.