我正在尝试在 macOS 上使用 clang++ 构建一个包含多个 *.cpp 文件的简单项目。
任务.json:
{
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "clang++ build active file",
"command": "/usr/bin/clang++",
"args": [
"-std=c++17",
"-Wall",
"-Wextra",
"-Weffc++",
"-Wconversion",
"-pedantic-errors",
"-stdlib=libc++",
"-g",
"${workspaceFolder}/*.cpp",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
Run Code Online (Sandbox Code Playgroud)
结果命令如下所示:
/usr/bin/clang++ -std=c++17 -Wall -Wextra -Weffc++ -Wconversion -pedantic-errors -stdlib=libc++ -g '/Users/USER/Developer/WORKINGDIR/Lesson 2/Lesson 2.8/*.cpp' -o '/Users/USER/Developer/WORKINGDIR/Lesson 2/Lesson 2.8/main'
Run Code Online (Sandbox Code Playgroud)
但编译器会抛出错误:
clang: error: no such file or …Run Code Online (Sandbox Code Playgroud)