将参数传递给C ++程序以在VSCode中进行调试

csz*_*ang 5 c++ cmdline-args visual-studio-code

我想在VSCode中调试C ++项目(在Mac上,使用GDB或LLDB)。程序本身接受命令行参数,例如

./prog -input cf file_x.txt
Run Code Online (Sandbox Code Playgroud)

在命令行上在GDB中启动调试会话时,这种方法可以正常工作。

在VSCode中,我试图适应launch.json这种阅读方式(仅显示相关行):

"program": "${workspaceRoot}/build/prog",
            "args": [
              "-input cf",
               "path_to/file_x.txt"
            ]
Run Code Online (Sandbox Code Playgroud)

这样,我进入@"Unknown option: \"-input cf\"\r\n"了输出并且未调试过程;或者,我只尝试了一个这样的参数:

"program": "${workspaceRoot}/build/prog",
            "args": [
              "-input cf path_to/file_x.txt"
            ]
Run Code Online (Sandbox Code Playgroud)

结果相同。我错过了重要的事情吗?

DAX*_*lic 6

像这样尝试

"program": "${workspaceRoot}/build/prog",
            "args": [
              "-input",
              "cf",
              "path_to/file_x.txt"
            ]
Run Code Online (Sandbox Code Playgroud)