问题描述
我安装了 C/C++ ms-vscode.cpptools 扩展(和 Code Runner)。 这是我的 task.json
"version": "2.0.0","tasks": [
{
"type": "cppbuild","label": "C/C++: gcc build active file","command": "/usr/bin/gcc","args": [
"-g","-Wall","${file}","-o","${fileDirname}/${fileBasenameNoExtension}"
],"options": {
"cwd": "${workspaceFolder}"
},"problemmatcher": [
"$gcc"
],"group": {
"kind": "build","isDefault": true
},"detail": "compiler: /usr/bin/gcc"
}
]
注意 args 部分中的 -Wall 选项。 当我编译并运行代码时,警告不会出现在我的终端中,只有错误。 我错过了什么吗?
解决方法
解决了code runner的配置也要修改。
"code-runner.executorMap": {
...
"c": "cd $dir && gcc -Wall $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",...
现在,如果我通过 VSCode 和代码运行器构建,我会显示警告。