clangd / coc-clangd

clangd extension for coc.nvim
Apache License 2.0
761 stars 34 forks source link

stdio.h not found but code still run #313

Closed hungpham3112 closed 3 years ago

hungpham3112 commented 3 years ago

I have a message like this: image but when i run it still be ok image I don't know why this happen? Thanks for helping !!!

kadircet commented 3 years ago

Can you read https://clangd.llvm.org/guides/system-headers and see if it helps?

fannheyward commented 3 years ago

Try add this to your coc-settings.json:

  "clangd.arguments": [
    "--query-driver=/usr/bin/clang++",
    "--background-index"
  ],
hungpham3112 commented 3 years ago

Try add this to your coc-settings.json:

  "clangd.arguments": [
    "--query-driver=/usr/bin/clang++",
    "--background-index"
  ],

It doesn't work to me

fannheyward commented 3 years ago

@Hungpro3112 you're using Windows, change query-driver to your path, check https://clangd.llvm.org/guides/system-headers#query-driver for more.

hungpham3112 commented 3 years ago

@Hungpro3112 you're using Windows, change query-driver to your path, check https://clangd.llvm.org/guides/system-headers#query-driver for more.

Windows makes me hard to install something like this. Should I change to use Linux or Mac ?

hungpham3112 commented 3 years ago

@Hungpro3112 you're using Windows, change query-driver to your path, check https://clangd.llvm.org/guides/system-headers#query-driver for more.

Here is my project image I put it like you said but still doesn't work image

snprajwal commented 3 years ago

I'm pretty sure Windows doesn't use the ~ environment variable outside of PowerShell. You need to put the complete path to your project folder like "C:\Users\You\Desktop\C_Project\Hello_World". Right-click on your folder and see Properties to get the full path.

hungpham3112 commented 3 years ago

I'm pretty sure Windows doesn't use the ~ environment variable outside of PowerShell. You need to put the complete path to your project folder like "C:\Users\You\Desktop\C_Project\Hello_World". Right-click on your folder and see Properties to get the full path.

Yeah it seems not have any messages anymore but it raises a new one image

fannheyward commented 3 years ago

@Hungpro3112 do you still have any errors with clangd?

hungpham3112 commented 3 years ago

@Hungpro3112 do you still have any errors with clangd?

No, it's really good

cody-quinn commented 1 year ago

@Hungpro3112 do you still have any errors with clangd?

No, it's really good

Hey when you close an issue saying you fixed your problem, but not actually providing how you fixed your problem, it makes it really frustrating for people seeing the issue later on 🙂

hungpham3112 commented 1 year ago

Hi @CatDevz, sorry for ambiguous comment. I was just starting to learn programming back then, so I didn't realize how important it was to answer a complete question for others.

It seems that clang didn't recognize the header file stdio.h. To show where clang searches for header file, open terminal and run:

clang -v -c -xc++ nul

It will be something like this:

clang version 16.0.6
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: C:\Users\sofia\scoop\apps\llvm\current\bin
 (in-process)
 "C:\\Users\\sofia\\scoop\\apps\\llvm\\current\\bin\\clang.exe" -cc1 -triple x86_64-pc-windows-msvc19.36.32537 -emit-obj -mrelax-all -mincremental-linker-compatible -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name nul -mrelocation-model pic -pic-level 2 -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -mllvm -treat-scalable-fixed-error-as-warning -v "-fcoverage-compilation-dir=C:\\Users\\sofia" -resource-dir "C:\\Users\\sofia\\scoop\\apps\\llvm\\current\\lib\\clang\\16" -internal-isystem "C:\\Users\\sofia\\scoop\\apps\\llvm\\current\\lib\\clang\\16\\include" -internal-isystem "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.36.32532\\include" -internal-isystem "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.36.32532\\atlmfc\\include" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.22621.0\\ucrt" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.22621.0\\shared" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.22621.0\\um" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.22621.0\\winrt" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.22621.0\\cppwinrt" -fdeprecated-macro "-fdebug-compilation-dir=C:\\Users\\sofia" -ferror-limit 19 -fmessage-length=120 -fno-use-cxa-atexit -fms-extensions -fms-compatibility -fms-compatibility-version=19.36.32537 -std=c++14 -fdelayed-template-parsing -fcxx-exceptions -fexceptions -fcolor-diagnostics -faddrsig -o nul.o -x c++ nul
clang -cc1 version 16.0.6 based upon LLVM 16.0.6 default target x86_64-pc-windows-msvc
ignoring nonexistent directory "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\atlmfc\include"
#include "..." search starts here:
#include <...> search starts here:
 C:\Users\sofia\scoop\apps\llvm\current\lib\clang\16\include
 C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\include
 C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt
 C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared
 C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um
 C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\winrt
 C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\cppwinrt

by default clang find header file in Windows Kits (SDK) with Visual Studio installer. If you don't have multiple paths like above you need download Visual studio. After installation, you will see image

Click to MSVC v143... and Windows 11 SDK, it will takes 5 minutes. After that clang can be recognize header file. Tell me if this solution didn't work for you, it's been a long time, now I don't work with C anymore. Thanks.

ghost commented 11 months ago

Absolutely nothing works.