微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决如何修复在 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 举报,一经查实,本站将立刻删除。