Skip to content

sourceFileMap not being applied to compileCommands #3918

Open
@therealkenc

Description

@therealkenc
  • OS and Version: Windows 18922
  • VS Code Version: 1.36.1
  • C/C++ Extension Version: 0.24.0

To reproduce, set up a launch.json with a "sourceFileMap", for example mine looks like:

            "sourceFileMap": {
                "/": "c:/Users/there/msys64/"
            }

Then in c_cpp_properties.json, enable "compileCommands". Mine looks like:

            "compileCommands": "${workspaceFolder}/build/compile_commands.json"

I am getting the following error from IntelliSense.

image

The build line from compile_commands.json looks like:

{
  "directory": "/home/there/Devel/mintty/build",
  "command": "/usr/bin/cc.exe    -std=gnu99 -include /home/there/Devel/mintty/src/std.h -Wall -Wextra -Wundef -Werror -g   -o src/CMakeFiles/wslterm.dir/winmain.c.o   -c /home/there/Devel/mintty/src/winmain.c",
  "file": "/home/there/Devel/mintty/src/winmain.c"
},

Debugging (breakpoints etc) works fine naturally, because the paths are being mapped okay. But it appears IntelliSense is unable to grok the paths in compile_commands.json, presumably because the path to winmain.c is not being mapped to c:/Users/there/msys64/home.../src. Which of course it isn't, because IntelliSense has no idea that mapping exists in launch.json (nor can it).

I guess the concrete ask is to add a "sourceFileMap" property to c_cpp_properties.json.

Or, I'm "doing it wrong".

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions