0

最近我升级到 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 和命令行工具

4

0 回答 0