Visual Studio Code shows red squiggles under #include <stdio.h> in the editor when the workspace is in ~/src but not when it is in /tmp. Both workspaces compile and run the code fine. It's only an error in the editor.
I can reproduce this with a very simple Hello World C workspace. I am using CMake along with CMake Tools. Versions:
- macOS Catalina 10.15.7
- CMake 3.19.5
- Visual Studio Code 1.53.2
- C/C++ Extension 1.2.1
- CMake Tools Extension 1.6.0
Here's the directory structure:
% tree hello_world
hello_world
├── CMakeLists.txt
└── main.c
Here's CMakeLists.txt:
cmake_minimum_required(VERSION 3.0.0)
project(hello_world VERSION 1.0.0)
add_executable(hello_world main.c)
Here's main.c:
#include <stdio.h>
int main(int argc, char** argv)
{
printf("hello world\n");
return 0;
}
Here's the screenshot for ~/src:
And here's the screenshot for /tmp:
Edit: Posted the output of "C/C++: Log Diagnostics" for both workspaces on a Gist. Here's part of the diff:
Includes:
- /usr/local/include
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.0/include
- /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
- Frameworks:
- /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/System/Library/Frameworks
So this explains why it cannot find it in one workspace, but not why the paths are different.


