【发布时间】:2021-11-15 21:22:34
【问题描述】:
我正在尝试将不同的优化级别(-O0、-O1、-O2、-O3 等)应用于 .cpp 文件的编译和执行。
但是,我无法弄清楚我需要使用的确切语法以及在哪里编写指令(即在哪个终端、VSCode 终端或 MinGW 终端)?
任何帮助将不胜感激。
tasks.json:
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: g++.exe build active file",
"command": "C:\\msys64\\mingw64\\bin\\g++.exe",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
},
{
"type": "cppbuild",
"label": "C/C++: cpp.exe build active file",
"command": "C:\\msys64\\mingw64\\bin\\cpp.exe",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": "build",
"detail": "compiler: C:\\msys64\\mingw64\\bin\\cpp.exe"
}
],
"version": "2.0.0"
}
【问题讨论】:
-
你应该有一些像
tasks.json这样的文件。你有吗? -
@RoQuOTriX 是的,我愿意。我该怎么办?
-
能否复制问题中文件的输入?应该有一些 args 字段,您可以在其中放置 g++ 编译器的参数
-
@RoQuOTriX 我已将 task.json 的内容添加到问题中。
标签: c++ visual-studio-code gcc compiler-optimization mingw-w64