skip to Main Content

I am using VS code together with the C/C++ and CMake extensions to develop a C project that is built with CMake. I have added a custom target to my CMakeLists.txt file that runs doxygen. I would like to see warnings from doxygen in the problems view of VS code. However they are not parsed, because doxygen doesn’t include the column in its output. It prints something like this:

/path/to/file.c:4: warning: Found unknown command '@xyz'

While VS code only parses something like this:

/path/to/file.c:4:2: warning: Found unknown command '@xyz'

Doxygen cannot print the column. My only option there would be to add a dummy column. Is there a way to change VS code’s behavior?

2

Answers


  1. You wrote, correctly:

    doxygen doesn’t include the column in its output

    I’m not sure about what you meant with / where to do this:

    My only option there would be to add a dummy column

    but indeed in doxygen you can accomplish this by changing the WARN_FORMAT setting to e.g.:

    WARN_FORMAT="$file:$line:1: $text"
    
    Login or Signup to reply.
  2. If you run doxygen as a task defined in tasks.json, you should be able to define your own custom problem matcher (put this in the "problemMatcher" field of a task in tasks.json. This is adapted from the example shown in VS Code’s help page on tasks, in the section on defining a problem matcher):

    {
      // The problem is owned by the cpp language service.
      "owner": "cpp",
      // The file name for reported problems is relative to the opened folder.
      "fileLocation": ["relative", "${workspaceFolder}"], // or just "absolute" if it's an absolute path
      // The actual pattern to match problems in the output.
      "pattern": {
        // The regular expression. Example to match: helloWorld.c:5:3: warning: implicit declaration of function ‘printf’ [-Wimplicit-function-declaration]
        "regexp": "^(.*):(\d+):(\d+):\s+(warning|error):\s+(.*)$",
        // The first match group matches the file name which is relative.
        "file": 1,
        // The second match group matches the line on which the problem occurred.
        "line": 2,
        // No match group matches the column at which the problem occurred.
        // "column": // not applicable
        // The third match group matches the problem's severity. Can be ignored. Then all problems are captured as errors.
        "severity": 3,
        // The fourth match group matches the message.
        "message": 4
      }
    }
    

    Otherwise, if this is behaviour you’re getting from an extension you have installed, you should go talk to the maintainer of that extension.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search