libzim icon indicating copy to clipboard operation
libzim copied to clipboard

[maintenence item] Remove transitive include dependencies

Open ThisIsFineTM opened this issue 11 months ago • 1 comments

Reliance on transitive includes can make the codebase more fragile for refactoring efforts both within the library codebase and for dependent projects. I ran into this issue when experimenting with zim-tools, where libzim's version.h has a dependency on <iostream>, but if <iostream> isn't included before #include <zim/version.h> there is a build error.

https://github.com/openzim/libzim/blob/c465e152d1bc71faffa5c7712185b3a4a39a8cd2/include/zim/version.h#L31 https://github.com/openzim/zim-tools/blob/768cbe534156a44abe7678493c12e52b2a3194a3/src/version.h#L23

There is a clang tool called Include What You Use (IWYU) which can do most of the work for this (with some spot checking).

If this is approved I can put in a PR.

ThisIsFineTM avatar Jan 09 '25 17:01 ThisIsFineTM

@veloman-yunkan @mgautierfr Please let us know if this is a good idea.

kelson42 avatar Apr 18 '25 04:04 kelson42