Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

forced include not parsed from compile_commands.json #5738

Closed
BMBurstein opened this issue Jul 7, 2020 · 6 comments
Closed

forced include not parsed from compile_commands.json #5738

BMBurstein opened this issue Jul 7, 2020 · 6 comments
Assignees
Labels
bug Feature: Configuration An issue related to configuring the extension or IntelliSense fixed Check the Milestone for the release in which the fix is or will be available. Language Service
Milestone

Comments

@BMBurstein
Copy link

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.

@Colengms Colengms self-assigned this Jul 7, 2020
@BMBurstein
Copy link
Author

BMBurstein commented Jul 7, 2020

I just noticed another (unrelated) maybe-issue in my log files: When using the compile_commands.json file, isn't the compiler path supposed to be extracted from there? (in my example it should be /usr/bin/g++ instead of /usr/bin/gcc)

@Colengms
Copy link
Contributor

Colengms commented Jul 7, 2020

Hi @BMBurstein . Thanks for reporting this. I believe we have a bug here, where we are only handling the -include arg properly if the file is referred to by absolute path or relative to the workspace folder.

@Colengms Colengms added bug Feature: Configuration An issue related to configuring the extension or IntelliSense Language Service labels Jul 7, 2020
@Colengms Colengms added this to the 0.29.0 milestone Jul 7, 2020
@BMBurstein
Copy link
Author

OK. To clarify more, in my case the file I was trying to force-include was in a directory that was listed with -I in the command line.

@Colengms Colengms added the fixed Check the Milestone for the release in which the fix is or will be available. label Jul 8, 2020
@sean-mcmanus
Copy link
Contributor

Should be fixed with https://github.com/microsoft/vscode-cpptools/releases/tag/0.29.0-insiders2 . Let us know if you still have problems with that.

@BMBurstein
Copy link
Author

It works. Thank you.
Out of curiosity, I wanted to look at the commit that fixed this, but could find no such commit. Can you point me to the fix?

@sean-mcmanus
Copy link
Contributor

The fix was in our closed source cpptools code.

@github-actions github-actions bot locked and limited conversation to collaborators Oct 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Feature: Configuration An issue related to configuring the extension or IntelliSense fixed Check the Milestone for the release in which the fix is or will be available. Language Service
Projects
None yet
Development

No branches or pull requests

3 participants