在VS Code中配置task.json文件,以在Mac上使用特定版本的C ++编译C ++

问题描述 投票:0回答:1

我正在尝试使用VS Code编译一些C ++代码,并且在使用其他C ++版本时遇到了一些麻烦。我想使用选项-std=c++17对其进行编译,因为有些事情我只需要测试C ++ 17中的工作(默认情况下,Clang使用C ++ 14)。因此,我尝试编辑tasks.json文件以手动添加使用C ++ 17的选项。但是,即使这样做,也似乎无济于事。

起初,我只编辑了[[g ++构建活动文件]的options部分],但是,由于它似乎不起作用,我将该选项添加到了所有任务中。不幸的是,这也没有帮助。你能告诉我我在哪里犯错了吗?您可以在下面的tasks,json文件中找到tasks部分。"tasks": [ { "type": "shell", "label": "clang build active file", "command": "/usr/bin/clang", "args": [ "-g", "${file}", "-o", "${fileDirname}/${fileBasenameNoExtension}", "-std=c++17" ], "options": { "cwd": "/usr/bin" }, "problemMatcher": [ "$gcc" ], "group": { "kind": "build", "isDefault": true } }, { "type": "shell", "label": "clang build active file", "command": "/usr/bin/clang", "args": [ "-g", "${file}", "-o", "${fileDirname}/${fileBasenameNoExtension}", "-std=c++17" ], "options": { "cwd": "/usr/bin" }, "problemMatcher": [ "$gcc" ], "group": "build" }, { "type": "shell", "label": "g++ build active file", "command": "/usr/bin/g++", "args": [ "-g", "${file}", "-o", "${fileDirname}/${fileBasenameNoExtension}", "-std=c++17" ], "options": { "cwd": "/usr/bin" }, "problemMatcher": [ "$gcc" ], "group": "build" } ]

我正在尝试使用VS Code编译一些C ++代码,并且在使用其他C ++版本时遇到了一些麻烦。我想用选项-std = c ++ 17编译它,因为我需要测试工作...
visual-studio-code compilation g++ clang
1个回答
0
投票
好,所以答案很简单,我实际上是在做正确的事情,但是在错误的地方。
© www.soinside.com 2019 - 2024. All rights reserved.