Let's say we have a header file A.h
which depends on things declared in B.h
and C.h
. B.h
also depends an C.h
and therefore includes it.
In this case we don't need to include C.h
in A.h
and it will compile just fine without it.
But I am wondering what the best course of action is in these cases. If B.h
somehow changes and no longer depends on C.h
, A.h
will break.
On the other hand if I think this through to the end it seems unneccessary/impractical to reinclude every single dependency.
A common case I have are standard libraries. In almost all my header files I would have to include <stdint.h>
and <stdbool.h>
. I often skip this because they were already included in one of the dependencies but this always feels kind of arbitrary.