Skip to content

forced include not parsed from compile_commands.json #5738

@BMBurstein

Description

@BMBurstein

Type: LanguageService

Describe the bug

  • VS Code Version: 1.46.1
  • C/C++ Extension Version: 0.29.0 insiders

I opened a single folder. I configured to use a compile_commnads.json file. One of the parameters in the command in that file is "-include", which is a forced-include, as well as some of "-I" and "-D" parameters. It seems like this extension fills in the Defines and Includes from the parsed command line, but not the forced-include. I tried to add the include to the forcedInclude setting, but when using a compile_commands.json, the other settings get ignored

Steps to reproduce

This is my compile_commands.json:

[
  {
    "directory": "/home/baruch/temp",
    "command": "/usr/bin/g++ -DTEST2 -Iinc2 -include test2.h main.cpp -o main",
    "file": "main.cpp"
  }
]
Logs
-------- Diagnostics - 7.7.2020, 21:20:11
Version: 0.29.0-insiders
Current Configuration:
{
    "name": "Linux",
    "includePath": [
        "inc"
    ],
    "defines": [
        "TEST"
    ],
    "compilerPath": "/usr/bin/gcc",
    "cStandard": "c18",
    "cppStandard": "c++17",
    "compileCommands": "compile_commands.json",
    "forcedInclude": [
        "test.h"
    ],
    "compilerArgs": [],
    "browse": {
        "path": [
            "inc",
            "${workspaceFolder}"
        ],
        "limitSymbolsToIncludedHeaders": true
    }
}
Translation Unit Mappings:
[ /home/baruch/temp/main.cpp ]:
    /home/baruch/temp/main.cpp
Translation Unit Configurations:
[ /home/baruch/temp/main.cpp ]:
    Process ID: 15667
    Memory Usage: 61 MB
    Compiler Path: /usr/bin/gcc
    Includes:
        /home/baruch/temp/inc2
        /usr/include/c++/7
        /usr/include/x86_64-linux-gnu/c++/7
        /usr/include/c++/7/backward
        /usr/lib/gcc/x86_64-linux-gnu/7/include
        /usr/local/include
        /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed
        /usr/include/x86_64-linux-gnu
        /usr/include
    Defines:
        TEST2
    Standard Version: c++17
    IntelliSense Mode: gcc-x64
    Other Flags:
        --g++
        --gnu_version=70500
Total Memory Usage: 61 MB



-------- Diagnostics - 7.7.2020, 21:25:44
Version: 0.29.0-insiders
Current Configuration:
{
    "name": "Linux",
    "includePath": [
        "${workspaceFolder}/**"
    ],
    "defines": [
        "TEST"
    ],
    "compilerPath": "/usr/bin/gcc",
    "cStandard": "c18",
    "cppStandard": "c++17",
    "forcedInclude": [
        "test.h"
    ],
    "compilerArgs": [],
    "browse": {
        "path": [
            "${workspaceFolder}/**"
        ],
        "limitSymbolsToIncludedHeaders": true
    }
}
Translation Unit Mappings:
[ /home/baruch/temp/main.cpp ]:
    /home/baruch/temp/main.cpp
Translation Unit Configurations:
[ /home/baruch/temp/main.cpp ]:
    Process ID: 16065
    Memory Usage: 60 MB
    Compiler Path: /usr/bin/gcc
    Includes:
        /usr/include/c++/7
        /usr/include/x86_64-linux-gnu/c++/7
        /usr/include/c++/7/backward
        /usr/lib/gcc/x86_64-linux-gnu/7/include
        /usr/local/include
        /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed
        /usr/include/x86_64-linux-gnu
        /usr/include
    Defines:
        TEST
    Forced Includes:
        /home/baruch/temp/inc/test.h
    Standard Version: c++17
    IntelliSense Mode: gcc-x64
    Other Flags:
        --g++
        --gnu_version=70500
Total Memory Usage: 60 MB

As you can see, in the first log I am using the compile_commands.json and I get the defines and include paths only from there (not from the configuration file), but I get neither forced include.
In the second log I am not using the compile_commands.json, and then I get the defines, include paths and forced includes from the configuration.

Metadata

Metadata

Assignees

Labels

Feature: ConfigurationAn issue related to configuring the extension or IntelliSenseLanguage ServicebugfixedCheck the Milestone for the release in which the fix is or will be available.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions