如何修复在 VScode 上找不到的“stdio.h”文件

问题描述

最近我升级到了 Big Sur(11.4)。 当我尝试在 C 中的 VS 代码中编码时,我收到警告“stdio.h”文件未找到 当我尝试编译它时,我收到错误

main.c:1:10: Fatal error: 'stdio.h' file not found
#include <stdio.h>
     ^~~~~~~~~

但是如果我使用终端并使用 clang 它编译就好了。它在 C++ 的情况下是一样的我得到错误

 In file included from x.cpp:1:
 In file included from /usr/local/opt/llvm/bin/../include/c++/v1/iostream:37:
 In file included from /usr/local/opt/llvm/bin/../include/c++/v1/ios:214:
 In file included from /usr/local/opt/llvm/bin/../include/c++/v1/iosfwd:95:
 /usr/local/opt/llvm/bin/../include/c++/v1/wchar.h:119:15: Fatal error: 'wchar.h' file not 
 found
 #include_next <wchar.h>

Xcode 工作正常,它也使用 gcc 进行编译,但仅在 VS 代码中出现错误。 这是我的 c_cpp_properties.json 文件

{
"configurations": [
    {
        "name": "Mac","includePath": [
            "${workspaceFolder}/**","/usr/local/Cellar/llvm/11.1.0/include/c++/v1"

        ],"defines": [],"macFrameworkPath": [],"compilerPath": "/usr/bin/clang","cStandard": "c17","cppStandard": "c++14","intelliSenseMode": "macos-clang-x64"
    }
],"version": 4
}

这是 task.json 文件

{
"version": "2.0.0","tasks": [
    {
        "type": "cppbuild","label": "C/C++: clang build active file","command": "/usr/bin/clang","args": [
            "-g","${file}","-o","${fileDirname}/${fileBasenameNoExtension}"
        ],"options": {
            "cwd": "${fileDirname}"
        },"problemmatcher": [
            "$gcc"
        ],"group": "build","detail": "compiler: /usr/bin/clang"
    }
]
}

我也安装了 xcode 和命令行工具

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)