Simon Marchi writes: >>> I check that by opening the file in my VSCode+clangd, if there is any >>> error reported it means something is missing. >> >> Thanks for mentioning; decided to give clangd a try and after some >> .clangd fiddling¹, I do get a warning-free ada-tasks.h with your >> amendments. I'm curious whether & how you configure it tho, since I get >> more spurious-looking diagnoses if I venture into other files²; I'm >> assuming I'm missing more compilation flags, and wondering how best to >> get an "authoritative" list & keep it up-to-date. >> >> (Searched gdb-patches because I'm sure you've mentioned your clangd >> setup before, but could not find my answers) >> >> (FWIW, I think that's the first language server I try with Eglot that >> defaults to enabling inlay hints & semantic tokens. Thanks for the >> hearty fruit salad 😀) >> >> >> ¹ Current state of affairs: >> >> > > I would not try to do it by hand, use a generated compile_commands.json > isntead. Do a clang build somewhere (if you don't have one already), > you can start with this and adjust to your liking: > > $ ../path/to/configure CC="ccache clang" CXX="ccache clang++" --enable-targets=all --with-python=python3 --with-guile --enable-sim --disable-werror > > Then build with "bear" to generate compile_commands.json: > > $ bear -- make -j $(nproc) > > If the build fails in a middle and you have to tweak something, do a > "make clean" and start over, because bear by default replaces the entire > compile_commands.json, so you could be missing what was previously > successfully compiled (or you could use "bear -a" I guess, but I prefer > starting from scratch). > > The reason I am using a clang build for this is that if you build with > gcc, then compile_commands.json will contain some flags unknown to > clang, and at least a long time ago clangd would warn about them. Maybe > that improved in the recent years. > > You can disable the directories you don't care about (e.g. "--disable-ld"). > > Then, make a symlink from your source dir to the compile_commands.json: > > $ cd path/to/source > $ ln -s path/to/clang/build/compile_commands.json > > Now, clangd should be mostly error-free when opening anything. Thanks for the recipe; worked flawlessly AFAICT. IOW, after 1. 'apt install bear ccache clang clangd' 2. your recipe, (more-or-less; see attached) 3. M-x eglot, Most LSP functions I cared to test before reporting seemed to work. "Friendship ended with 'make TAGS', .dir-locals.el & tags-table-list; now 'bear -- make', compile_commands.json, clangd & Eglot are my best friends", as the meme goes. (Tho I really need to 'M-x customize-group eglot-semantic-fontification'; the current colors feel like nyan-mode got sick of the mode-line and broke containment) >> ² E.g. all members of gdb/ada-tasks.c:struct ada_tasks_pspace_data are >> flagged with >> >>> clang [expected_semi_decl_list]: Expected ';' at end of declaration list > > It's not expected, let's see if that goes away once you have a > compile_commands.json. The error did go away. Reviewing compile_commands.json, the missing piece might have been just '-x c++': if I scrap compile_commands.json, restore my handcrafted .clangd and add that switch, those specific errors on struct ada_tasks_pspace_data do go away. Tho there's still a dozen more errors, so I'll keep compile_commands.json for now. Again, thanks for taking the time to describe your setup, that's going to help me with much more than just include hygiene. (And as for the series, will submit v4 momentarily)