Skip to content

auto-populate the browse.path when compileCommands is used #1715

@tksuoran

Description

@tksuoran

I try to get use compile commands json, but I do not get it to work. I have included a minimal repro project files inline below.

Repro steps - case 1 - define:

  • Open foo/main.c (and have no other files open)
  • Hover mouse over RETURN_VALUE
  • Right click and "Go to Definition"

Result I observe:

  • Message "No definition found for 'RETURN_VALUE'"

Expected result:

  • Editor opens bar/header.h

I also cannot use Go to Definition to navigate to the header file. If header.h is already open, then Go to Definition works.

  • Extension Name: cpptools
  • Extension Version: 0.15.0
  • OS Version: Linux x64 4.13.0-37-generic
  • VSCode version: 1.21.1

We have written the needed data into your clipboard. Please paste:

{
	"activationTimes": {
		"startup": false,
		"codeLoadingTime": 123,
		"activateCallTime": 7,
		"activateResolvedTime": 526,
		"activationEvent": "onLanguage:c"
	}
}

.vscode/c_cpp_properties.json:

{
    "configurations": [
        {
            "name": "Linux",
            "compileCommands": "${workspaceRoot}/compile_commands.json",
            "includePath": [],
            "defines": [],
            "intelliSenseMode": "clang-x64",
            "browse": {
                "path": [],
                "limitSymbolsToIncludedHeaders": false,
                "databaseFilename": ""
            }
        }
    ],
    "version": 3
}

.vscode/settings.json:

{
    "C_Cpp.intelliSenseEngine": "Default"
}

compile_commands.json:

[
    {
        "directory": "foo",
        "file": "main.c",
        "arguments":
        [
            "/usb/bin/clang",
            "-Ibar",
            "foo/main.c"
        ],
        "command": "/usr/bin/clang -Ibar foo/main.c"
    }
]

foo/main.c:

#include "header.h"

int main(int argc, char** argv)
{
    return RETURN_VALUE;
}

bar/header.h:

#define RETURN_VALUE (0)

build.sh:

#!/bin/bash
clang -Ibar foo/main.c

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions