codegraph icon indicating copy to clipboard operation
codegraph copied to clipboard

Support C++ forced includes

Open ryancu7 opened this issue 5 months ago • 2 comments

We compile our large C++ project with a "forced include" option, where a particular header file in our repo is always included, even when there is no #include directive in the current source file. This header defines all our common typedefs we use everywhere. CodeGraph is not coping very well with our codebase and I suspect this is a reason. Can it be made to support this?

ryancu7 avatar Jun 29 '26 01:06 ryancu7

CodeGraph doesn't follow #include directives to resolve symbols — it indexes every source/header file in your repo and resolves references by matching symbol names across the whole graph. So a forced-include header is already fully indexed, and the typedefs/structs/functions it defines are already visible to every file, with no #include needed. The missing directive isn't what's hurting you here.

To find the actual cause, can you share a concrete example of what looks wrong? e.g. a call or type that should link to a definition but doesn't, or impact/callers that come back empty. A few specifics will tell us whether it's #1043 (inheritance from templated bases — just fixed, shipping in the next release), the way we currently handle types used only as local-variable declarations, or something else.

One thing worth checking: is your forced-include header inside the indexed repo? If it lives outside the tree (an SDK/system path passed via -include), its symbols wouldn't be in the graph — that we can help with.

colbymchenry avatar Jun 29 '26 01:06 colbymchenry

Thanks for explaining this. I think #1043 was the main problem and v1.1.3 is working much better. ❤️

ryancu7 avatar Jun 29 '26 08:06 ryancu7