VS Code cannot see pthread.h
but the program compiles and works fine, it is just the fact that the file appears as red, pointing to that line. I am working on Windows 11, using WSL, with the C/C++ extension enabled. It's a really annoying bug, for which I found no fix.
Asked
Active
Viewed 295 times
0

Alexandru Manolache
- 31
- 3
-
Did you try to update your IncludePath as the message tells you? – Gerhardh Oct 29 '22 at 09:11
-
See [VS Code: Customize default settings](https://code.visualstudio.com/docs/cpp/customize-default-settings-cpp) – Gerhardh Oct 29 '22 at 09:13
-
3Does this answer your question? [#include errors detected. Please update your includePath in visual studio code](https://stackoverflow.com/questions/68323394/include-errors-detected-please-update-your-includepath-in-visual-studio-code) – Gerhardh Oct 29 '22 at 09:13
-
My include path is ${workspaceFolder}/**, how should I change it to aggregate pthread.h? – Alexandru Manolache Oct 29 '22 at 09:41
-
You only include files from your workspace. There is barely a chance this will include compiler headers. Where is your include folder? Where is `pthread.h` located? Find and add that folder. – Gerhardh Oct 29 '22 at 09:42
-
I didn't download pthread.h, and since my program works well I think it's downloaded by default. I will search for it and add it. – Alexandru Manolache Oct 29 '22 at 09:43
-
That is not strange at all if you look at the details: VS Code is an editor. It tries to see what the compiler might see. The compiler is a different program with different default folders. It knows where to look, at least for the standard headers. The editor does not unless you tell it. – Gerhardh Oct 29 '22 at 09:44
-
Please don't post images of text. Post the *actual text* instead. – Jesper Juhl Oct 29 '22 at 09:57
-
Copying the path and including it does not work, vscode doesn't see it: https://imgur.com/a/KHEAWN4 Any suggestion regarding this? – Alexandru Manolache Oct 29 '22 at 09:57
-
I think the problem is generated by the wsl, since I don't have the actual tools needed for c++ on my host, and it seems that vs code cannot see files inside the wsl. – Alexandru Manolache Oct 29 '22 at 10:00
-
write the include paths as if you work on the remote, not how the local VSC sees the remote, local VSC is just a viewer of the remote VSC, the C language server runs on the remote, change the setting files on the remote – rioV8 Oct 29 '22 at 10:30
1 Answers
0
Fix: installing pthread.h on host using vcpkg The vcpkg folder needs to be added to path.

Alexandru Manolache
- 31
- 3
-
1You shouldn't need to do it. It should be possible to configure VSC to use the files on the remote directly. – HolyBlackCat Oct 29 '22 at 11:43