为什么我的VSCODE检查C+ 17(我的编译器是Clang 12)?

发布于 2025-02-11 01:05:42 字数 824 浏览 3 评论 0原文

这是我的远程服务器和本地vscode

此遵循

    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/**",
                "/usr/include"
            ],
            "defines": [],
            "compilerPath": "/usr/bin/clang++-12",
            "cStandard": "gnu11",
            "cppStandard": "c++17",
            "intelliSenseMode": "linux-clang-x64",
            "configurationProvider": "ms-vscode.cmake-tools"
        }
    ],
    "version": 4
} 

我的远程C_CPP_PROPERTIES中的上下文。 VSCODE文件夹

设置。JSON:

"C_Cpp.default.cppStandard": "c++17",
    "clang.cxxflags": [
        "-std=c++17"
    ],

但是我的代码可以编译

This follow is my remote server and local vscode

this follow context

    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/**",
                "/usr/include"
            ],
            "defines": [],
            "compilerPath": "/usr/bin/clang++-12",
            "cStandard": "gnu11",
            "cppStandard": "c++17",
            "intelliSenseMode": "linux-clang-x64",
            "configurationProvider": "ms-vscode.cmake-tools"
        }
    ],
    "version": 4
} 

in my remote c_cpp_properties.json under .vscode folder

settings.json:

"C_Cpp.default.cppStandard": "c++17",
    "clang.cxxflags": [
        "-std=c++17"
    ],

but my code can be compiled

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

奢欲 2025-02-18 01:05:42

此问题是因为有一个CMAKE工具插件,请在远程服务器中找到您的compile_commands.json文件,然后编辑以添加选项-STD = C ++ 17;因此,将例如更改

"command": "/usr/bin/clang++-12   -g -o CMakeFiles/linuxCode.dir/main.cpp.o -c  /home/source/main.cpp",

"command": "/usr/bin/clang++-12   -g -o CMakeFiles/linuxCode.dir/main.cpp.o -c -std=c++17 /home/source/main.cpp",

This problem is because of a cmake tool plugin, find your compile_commands.json file in your remote server, and edit to add the option -std=c++17; thus, change e.g.

"command": "/usr/bin/clang++-12   -g -o CMakeFiles/linuxCode.dir/main.cpp.o -c  /home/source/main.cpp",

to

"command": "/usr/bin/clang++-12   -g -o CMakeFiles/linuxCode.dir/main.cpp.o -c -std=c++17 /home/source/main.cpp",
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文