On Thu, Apr 13, 2023 at 9:11 PM Joel Fernandes <joel@xxxxxxxxxxxxxxxxx> wrote: > > Hello, > > One way to fix this could be to add this to the beginning of tree_nocb.h > > /* Make clangd understand tree_nocb.h */ > +#ifdef CLANGD_PARSER_ACTIVE > +#define TREE_NOCB_H_CLANGD > +#include "tree.c" > +#endif > > And then at the end of tree.c, do this to prevent recursion: > +#ifndef TREE_NOCB_H_CLANGD > #include "tree_nocb.h" > -#include "tree_plugin.h" > +#endif > +#include "tree_plugin.h" > > Then in scripts/clang-tools/gen_compile_commands.py, we can just make > it add "-DCLANGD_PARSER_ACTIVE" to all compile command entries in the > JSON file. > Ah and even that will not fully work, because there is no entry for tree_nocb.h in compile_commands.json to begin with :-(. However, that also can be fixed. Here's how: We can just add metadata to tree_nocb.h , something like: /* clangd_infer_from: tree.c */ Then we make scripts/clang-tools/gen_compile_commands.py duplicate the compile command JSON entry for tree.c but for tree_nocb.h. Lastly, we add -DDCLANGD_PARSER_ACTIVE to all entries (including the duplicate). - Joel