clangd / clangd

clangd language server
https://clangd.llvm.org
Apache License 2.0
1.58k stars 64 forks source link

<cerrno> is suggested instead of <errno.h> for errno values when `-std=c99` #2056

Open Thalley opened 6 months ago

Thalley commented 6 months ago

When compiling .c files with -std=c99 the Include Cleaner will suggest to include <cerrno> instead of <errno.h> which it shouldn't. <cerrno> is arguably only the correct choice for C++ programs.

Logs N/A

System information

$ clangd --version
clangd version 17.0.6
Features: linux
Platform: x86_64-pc-linux-gnu

Editor/LSP plugin: https://marketplace.visualstudio.com/items?itemName=llvm-vs-code-extensions.vscode-clangd

Operating system: Arch Linux

Steampunkery commented 5 months ago

I have the same issue on clangd 18.1.3. I am using -std=c17 and clangd is suggesting #include <cstdio> for exit(1)

Thalley commented 5 months ago

Just to add to that; I also see a lot more C++ header being suggested for C than just cerrno>

Dappstr commented 1 week ago

I am observing similar behavior with -std=c11 in eglot in gnu emacs using clangd on Windows when attempting to use the INT_MIN macro, <climits> is being suggested.

clangd version 18.1.3 (https://github.com/llvm/llvm-project c13b7485b87909fcf739f62cfa382b55407433c0) Features: windows+grpc Platform: x86_64-pc-windows-msvc