Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[regression] "compileCommands" is ignored when custom tool chain is used by project #3102

@lsmgeb89

Description

@lsmgeb89

Type: LanguageService

Describe the bug

  • OS and Version: Ubuntu 18.04.1 LTS
  • VS Code Version:
    Version: 1.30.2
    Commit: 61122f88f0bf01e2ac16bdb9e1bc4571755f5bd8
    Date: 2019-01-07T22:49:48.319Z
    Electron: 2.0.12
    Chrome: 61.0.3163.100
    Node.js: 8.9.3
    V8: 6.1.534.41
    OS: Linux x64 4.15.0-43-generic
    
  • C/C++ Extension Version: Version 0.21.0 January 23, 2019
  • Other extensions you installed (and if the issue persists after disabling them):
  • A clear and concise description of what the bug is: Current version of cpptools ignores the compileCommands attribute so that header files could not be found and IntelliSense falls back to tag parser. But the same config works in the previous version of cpptools.

To Reproduce

  • Below configs are generalized to omit project details, but kept accurate folder structures.
  • Here is the c_cpp_properties.json for the previous version of cpptools:
    {
        "configurations": [
            {
                "name": "Linux",
                "compileCommands": "${workspaceFolder}/compile_commands.json",
                "includePath": [
                    "${workspaceFolder}/**"
                ],
                "defines": [],
                "compilerPath": "/home/bob/toolchain/bin/g++ --sysroot=/home/bob/toolchain",
                "cStandard": "c11",
                "cppStandard": "c++14",
                "intelliSenseMode": "gcc-x64"
            }
        ],
        "version": 4
    }
    and compile_commands.json contains a lot of entries like below.
    [
      {
        "directory": "/home/bob/proj/foo",
        "command": "ccache g++ -I/home/bob/proj -std=c++14 -D__FOO_BAR__ -Wall -Werror --sysroot /home/bob/toolchain -o CMakeFiles/foo.dir/bar.cc.o -c /home/bob/proj/foo/bar.cc",
        "file": "/home/bob/proj/foo/bar.cc"
      },
      {
        "...": "..."
      }
    ]
  • After upgrading to current version of cpptools, above config does NOT work. Header files could not be found properly by showing errors like "cannot open source file ..." and "#include errors detected. Consider updating your compile_commands.json or includePath. IntelliSense features for this translation unit (/home/bob/proj/foo/bar.cc) will be provided by the Tag Parser."
  • After update c_cpp_properties.json to below, the errors disappear.
    {
        "configurations": [
            {
                "name": "Linux",
                "includePath": [
                    "${workspaceFolder}/**",
                    "/home/bob/toolchain/include/**"
                ],
                "defines": [],
                "compilerPath": "/home/bob/toolchain/bin/g++ --sysroot=/home/bob/toolchain",
                "cStandard": "c11",
                "cppStandard": "c++14",
                "intelliSenseMode": "gcc-x64"
            }
        ],
        "version": 4
    }

Expected behavior

  • But second version of c_cpp_properties.json does NOT contain "compileCommands" so that first version is better than second version because compile_commands.json provides the most accurate information.
  • So expected behavior is to at least make first version of c_cpp_properties.json works.
  • A better way is to define a clear support for the project by using custom tool chain. Define what attribute should be provided in the c_cpp_properties.json so that many similar issues related to custom tool chain could be resolved.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Language ServicebugfixedCheck the Milestone for the release in which the fix is or will be available.regressionA bug that didn't exist in a previous release

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions