Clangd shows false errors when compilation works just fine

463 views Asked by At

I usd clangd as my language server for C in Neovim. I recently cloned a few C source code repositories (Suckless's DWM and Neovim) and wanted to take a look at the source code. Clangd gave me errors that did not occur during compilation.

I did not modify the source files in any way, shape or form. I don't know how to describe some of these errors other than by giving examples.

Including some header files resulted in errors. In dwm.c, for X11 header files (#include <X11/Xft/Xft.h>), I got a "In included file: 'ft2build.h file not found" error (but the file exists). Same in neovim/src/nvim/main.c with #include nvim/arglist.h.

I have errors like "Expected ')'" in dwm.c in

updatestatus(void)
{
    if (!gettextprop(root, XA_WM_NAME, stext, sizeof(stext)))
        strcpy(stext, "dwm-"VERSION); // Error is on this line
    drawbar(selmon);
}

For Neovim, some of these include: "Unknown type name 'Loop'" in neovim/src/main.c (permalink) on line 122: Loop main_loop; and "Initializer element is not a compile-time constant on line 127: static const char *err_arg_missing = N_("Argument missing after");.

Obviously, one would expect these to fail to compile, but they compile without any kind of error and work (I've run both of them after compiling). How should I fix this?

0

There are 0 answers