It could happen that two independent libraries have two header files with identical include guards.
The following example is like that; as a consequence, the second include file is blocked by the first one.
Is this ever be a real problem? Users don't always have the luxury of editing a library.
What is the usual way to handle such a situation if the user can not edit the library?
I ran into this situation with my own libraries, so I simply changed the include guard.
#include "lib1/A.h"
#include "lib2/A.h" //has identical include guard as lib1/A.h
int main()
{
lib1::fn();
lib2::fn(); //error: 'lib2' has not been declared (blocked by include guard)
}
The root of the problem seems to be the shitty naming scheme. Is 'A' really the best name for that that file?
So the answer to your question is yes, If the header guards are implemented in a simplistic way. Although it isn't strictly standardized, most implementations of C++ will recognize the #pragma once directive which is usually a better header guard than the standard #ifdef/#define scheme as it generates file-specific identifiers behind the scenes. However, it may not be portable.