一、简易多文件编译
vscode 中C++运行编译运行多文件问题总结_audioFrame的博客-CSDN博客_vscode编译多个文件
这篇博客下一位老哥的解决方法(官方文档里也有),只要在tasks.json里修改"args"那一项就好了。适用与简易多文件编译,大项目还是需要Cmake或者Makefile
"args": [
"-g",
"${file}", //单文件编译
// "${fileDirname}\\*.cpp",//这里是多文件编译,在同一个目录下
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe",
"-L",
"D:\\C++\\C++_code",//这里是我的文件保存的路径
"-l",
"ws2_32"
],
单文件的时候就把 "${fileDirname}\\*.cpp" 注释掉
多文件就把 "${file}" 注释掉
官方文档:
${file} - the current opened file
${fileWorkspaceFolder} - the current opened file's workspace folder
${fileDirname} - the current opened file's dirname
二、命令行参数
在launch.json中设置
launch.json中将
"args": [],修改为
"args": ["command_1","command_2"],//command_n是你自己输入的具体参数
以上均详情可见官方文档