C++:在 VSCode 中生成预处理文件
构建任何 C/C++ 代码都会生成 .exe
文件。有什么办法可以为 ex 生成另一个文件吗? preprocessed.txt
其中将包含预处理代码? tasks.json 中需要修改什么吗?
这是我通常使用的 json 文件:
{
"version": "2.0.0",
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: g++.exe build active file",
"command": "C:\\Program Files\\CodeBlocks\\MinGW\\bin\\g++.exe",
"args": [
"-fdiagnostics-color=always",
"-g",
"${workspaceFolder}\\*.cpp",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "compiler: \"C:\\Program Files\\CodeBlocks\\MinGW\\bin\\g++.exe\""
}
]
}
Building any c/c++ code generates .exe
file. Is there any way that there will be another file generated for ex. preprocessed.txt
which will contain preprocessed code? Anything that needs to be modified in tasks.json?
Here is the json file i normally use:
{
"version": "2.0.0",
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: g++.exe build active file",
"command": "C:\\Program Files\\CodeBlocks\\MinGW\\bin\\g++.exe",
"args": [
"-fdiagnostics-color=always",
"-g",
"${workspaceFolder}\\*.cpp",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "compiler: \"C:\\Program Files\\CodeBlocks\\MinGW\\bin\\g++.exe\""
}
]
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
添加 -E 而不是 -o 它不会生成 .i 文件,但会在终端中生成预处理代码。
Add -E instead of -o it won't generate a .i file but it will produce the preprocessed code in the terminal..