C语言 在包含目录中找不到 Visual Studio Code 包含文件 (Windows 10)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/39430277/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Visual Studio Code include file not found in include directory (Windows 10)
提问by syy
I am trying to get intellisense in Visual Studio Code. I downloaded the the C/C++ extension from the marketplace: https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptoolsand also installed MinGW with the packages mingw32-baseand mingw32-gcc-c++. I added the MinGW binfolder to Pathin my Environment variables.
我正在尝试在 Visual Studio Code 中获得智能感知。我从市场下载了 C/C++ 扩展:https: //marketplace.visualstudio.com/items?itemName =ms-vscode.cpptools 并且还安装了 MinGW 和包mingw32-base和mingw32-gcc-c++. 我将 MinGWbin文件夹添加到Path我的环境变量中。
When I add any includestatement in my .cfile, such as #include <stdio.h>, Visual Studio Code says:
当我include在.c文件中添加任何语句时,例如#include <stdio.h>,Visual Studio Code 会说:
Include file not found in include directory
Am I not configuring correctly? How can I get intellisense for C/C++?
我没有正确配置吗?如何获得 C/C++ 的智能感知?
回答by wbmrcb
You have to create a c_cpp_properties.json first (use Ctrl+Shift+Pand "C/Cpp: Edit Configurations" command).
你必须先创建一个c_cpp_properties.json(使用Ctrl+ Shift+P和“C / CPP:编辑配置”命令)。
Add inlude paths as,
将引入路径添加为,
{
"configurations": [
{
"name": "Win32",
"includePath": [
"path_to_your/MinGW/lib/gcc/mingw32/4.8.1/include/c++"
],
"browse": {
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
}
}
]
}
回答by fatihpense
As an expansion to wbmrcb's answer, I found header files under Windows Kits directory:
作为 wbmrcb 答案的扩展,我在 Windows Kits 目录下找到了头文件:
C:\Program Files (x86)\Windows Kits\Include.0.10586.0\ucrt
回答by Marcel Zebrowski
On Fedora linux I added the following path where all my c header files lives.
在 Fedora linux 上,我添加了以下所有 c 头文件所在的路径。
/usr/include/**
/usr/include/**
to myc_cpp_properties.json file.
到 myc_cpp_properties.json 文件。
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**",
"/usr/include/**"
],
...
}
],
"version": 4
}

