3 ms·
Not including headers in header files can be confusing. Say you maintain a library (lib1.h) that exports an API that takes in an argument defined in lib2.h. I
by Cyph0n 6y ago
Not including headers in header files can be confusing.
Say you maintain a library (lib1.h) that exports an API that takes in an argument defined in lib2.h.
If you do not include lib2.h in lib1.h, then the users of your API need to include lib2.h before lib1.h in every source file and header. With a larger number of dependencies, this can become unwieldy for users.
In addition, future maintainers of your library may also find it confusing why things break when includes are reordered.