Mbed-cli in VSCode, problem with parsing compiler output

I’m using VSCode and for compiling tasks that call mbed-cli compile. That works fine, execpt capturing warnings.
mbed-cli or build.py filter the output from gcc, for a warning only the filename is displayed like this:

[Warning] MQTTThreadedClient.cpp@798,32: comparison of integer expressions of different signedness: ‘int’ and ‘unsigned int’ [-Wsign-compare]

But when the path is omitted, the IDE cannot jump to the warning location.
Errors are treated different, additional to the error line, the gcc error output is displayed.
Could this be modified?

in VSCode tasks.json my problemMatcher looks like this:

"problemMatcher": {
        "owner": "cpp",
        "pattern": {
            "regexp": "\\[(Warning|Error)\\] (.*)@(\\d+),(\\d+):(.*)",
            "severity": 1,
            "file": 2,
            "line": 3,
            "column": 4,
            "message": 5
        }
    },

the regexp is able to find a warning or error, but the path relative to projectroot is missing.

I found some setting in mbed-os/tools/settings.py:

# Print compiler warnings and errors as link format
PRINT_COMPILER_OUTPUT_AS_LINK = True

but when I activate this in mbed_settings.py in my project root, it has no effect.
How to enable mbed_settings.py?

ok, mbed_settings.py is usually used by default.

But I’m using a configuration with multiple projects and one mbed-os, as documented in
https://os.mbed.com/docs/mbed-os/v5.14/tools/working-with-mbed-cli.html

But it looks like mbed_settings is ignored or not found in this configuration. When mbed-os is in the current project dir and the config var MBED_OS_DIR is not set, than it works and I can override PRINT_COMPILER_OUTPUT_AS_LINK.

When MBED_OS_DIR is used, the mbed_settings.py in the project dir is also not compiled by python.

another Edit:
Terrific! It works! I just had another mbed_settings.py in the mbed-os directory. This was not tracked by git, so I have overseen it. After deleting, the mbed_settings.py in the project root was used and PRINT_COMPILER_OUTPUT_AS_LINK is set as intended.
Now mbed-cli and VSCode work together perfectly, also with multiple projects in workspaces. I can really recommend this configuration.

2 Likes