VSCode导入#include <stdio.h>文件时提示以下错误:
#include errors detected. Please update your includePath. IntelliSense features for this translation unit (/wk/c01/main.c) will be provided by the Tag Parser.cannot open source file "stddef.h" (dependency of "stdio.h")
这是由于配置中没有指定依赖路径导致的,在c_cpp_properties.json中includePath的默认配置只有当前目录,需要将系统依赖加入。
在命令行里面输入 gcc -v -E -x c++ -
在结果里面找到头文件目录,然后添加到includepath中。
注意,这里根据 VS code 操作的是LInux 和 Windows下的文件会有所不同,解决办法不一样
对于使用 VScode 连接Linux,操作Linux下的C++文件出现这个问题的解决办法是:
在terminal 中输入 gcc -v -E -x c++ -
,然后将最下的路径复制到 c_cpp_properties.json中 includePath下
如果输入上面的命令后提示 gcc 命令不存在,那说明当前Linux还有安装gcc, 那应该先输入下面的命令安装gcc, 然后输入上面的命令
yum -y install gcc gcc-c++ kernel-devel //安装gcc、c++编译器以及内核文件
配置好的 c_cpp_properties.json 文件如下:
如果你是用 VS code 遍历windows下的c++文件,然后出现这个问题
那么应该先按快捷键 Win + R, 然后输入 cmd, 在命令行窗口中输入 gcc -v -E -x c++ -
然后复制最下面的路径到 c_cpp_properties.json中 includePath下即可
