问题描述
我已经开始学习c
,我尝试将它与VS
代码一起使用,但是#include <stdio.h>
以绿色突出显示,并显示以下错误消息:
I have started to learn c
, I tried to use it with VS
Code, but the #include < stdio.h>
is highlighted in green with this error message:
#include errors detected. Please update your includePath. IntelliSense features for this translation unit
(C:\Users\Jerlam\Desktop\C\training\dweight.c) will be provided by the
Tag Parser.
could not open source file "stdio.h" (no directories in search list)
我看过一些关于这个问题的话题,但没有一个能帮我解决这个问题.
这是我的 c_cpp_properties.json
文件,我必须在其中添加路径(stdio
).事实上,关于它的文档绝对不是初学者友好的.
I have seen some topics about this issue, but none of them helped me to fix it.
Here is my c_cpp_properties.json
file in which I have to add the path (of stdio
). In fact the documentation about it is absolutely not beginner friendly.
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**",
"C:/Program Files (x86)/Windows Kits/10/Include/10.0.10240.0/ucrt"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"intelliSenseMode": "clang-x64"
}
],
"version": 4
}
我手动添加了这个路径:
I have added manually this path:
"C:/Program Files (x86)/Windows Kits/10/Include/10.0.10240.0/ucrt"
因为它包含 stdio.h
标头.
我该怎么办?谢谢.
推荐答案
感谢这个关于如何在 Windows 10 (VS Code) 上使用 Visual Studio Code 设置 C++ 开发.
我启动了 MinGW 安装管理器并安装了基本设置中的所有包.
我在系统环境变量中添加了gcc编译器的路径:C:\MinGW\bin
,其中是gcc.exe
.
I added the path of the gcc compiler to my system´s environment variables: C:\MinGW\bin
, in which is the gcc.exe
.
我打开了 c_cpp_properties.json 文件并为我想要包含的文件夹添加了不同的路径.所以现在我的 c_cpp_properties.json
文件看起来像这样:
I opened the c_cpp_properties.json file and added different paths for the folders I want to include. So now my c_cpp_properties.json
file looks like this:
{
"configurations": [{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**",
"C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.10240.0\\ucrt",
"C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\include",
"C:\\MinGW\\lib\\gcc\\mingw32\\6.3.0",
"C:\\MinGW\\lib\\gcc\\mingw32\\6.3.0\\include\\c++",
"C:\\MinGW\\lib\\gcc\\mingw32\\6.3.0\\include"
],
"defines": ["_DEBUG", "UNICODE", "_UNICODE"],
"intelliSenseMode": "clang-x64"
}],
"version": 4
}
这篇关于Visual Studio Code 给我“检测到#include 错误"对于 C的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!