17

I want to debug a C++ project in VSCode (on a Mac, using either GDB or LLDB). The program itself takes command line arguments like

./prog -input cf file_x.txt

This works fine when starting a debugging session in GDB on the command line.

In VSCode, I tried to adapt launch.json to read like this (only relevant lines shown):

"program": "${workspaceRoot}/build/prog",
            "args": [
              "-input cf",
               "path_to/file_x.txt"
            ]

With this, I get @"Unknown option: \"-input cf\"\r\n" in the output and the process is not debugged; alternatively, I tried only one argument like so:

"program": "${workspaceRoot}/build/prog",
            "args": [
              "-input cf path_to/file_x.txt"
            ]

resulting in the same message. Have I missed something important?

Gama11
  • 31,714
  • 9
  • 78
  • 100
cszang
  • 198
  • 1
  • 1
  • 7

2 Answers2

25

Try it like this

"program": "${workspaceRoot}/build/prog",
            "args": [
              "-input",
              "cf",
              "path_to/file_x.txt"
            ]
DAXaholic
  • 33,312
  • 6
  • 76
  • 74
  • 1
    I know this is old but this page will be updated with changes. https://code.visualstudio.com/docs/cpp/launch-json-reference#_args – Cody W Nov 10 '22 at 21:26
0

In 2022, I just do :

 "args": [
    "your_arg1",
    "your_arg2"
 ]

(in launch.json of course)

l_t_m_f
  • 11
  • 1