Skip to content

includePath doesn't work but when I forceInclude all intelsense error are gone #13445

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

Open
0xMALVEE opened this issue Apr 1, 2025 · 6 comments
Labels
Feature: Configuration An issue related to configuring the extension or IntelliSense Language Service

Comments

@0xMALVEE
Copy link

0xMALVEE commented Apr 1, 2025

Environment

  • OS and Version: Fedora 41
  • VS Code Version: c++
  • C/C++ Extension Version: latest
  • If using SSH remote, specify OS of remote machine:

Bug Summary and Steps to Reproduce

Bug Summary:

Image
this is the error

    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/bpf/**",
                "${workspaceFolder}/bpf/include"
            ],
            "forcedInclude": [
                // "${workspaceFolder}/bpf/include/type_mapper.h"
            ],
            "defines": [],
            "compilerPath": "/usr/bin/gcc",
            "cStandard": "c17",
            "cppStandard": "c++98",
            "intelliSenseMode": "linux-gcc-x64"
        }
    ],
    "version": 4
}

the errors goes away only if I use forceInclude

  "forcedInclude": [
                "${workspaceFolder}/bpf/include/type_mapper.h"
            ],

why I have to forceInclude there is a lot of projects & a lot of files it's not possible to force include each and every file.
Steps to reproduce:

install fedora 41 vs code & c++ extension
repo: https://github.com/cilium/tetragon

Expected behavior:
there should be 0 intelsense errors

Configuration and Logs

c_cpp_properties.json


{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/bpf/**",
                "${workspaceFolder}/bpf/include"
            ],
            "forcedInclude": [
                // "${workspaceFolder}/bpf/include/type_mapper.h"
            ],
            "defines": [],
            "compilerPath": "/usr/bin/gcc",
            "cStandard": "c17",
            "cppStandard": "c++98",
            "intelliSenseMode": "linux-gcc-x64"
        }
    ],
    "version": 4
}



C/C++: Log Diagonstics
-------- Diagnostics - 4/2/2025, 1:49:50 AM
Version: 1.23.6
Current Configuration:
{
    "name": "Linux",
    "includePath": [
        "/home/malvee/code/tetragon/bpf/**",
        "/home/malvee/code/tetragon/bpf/include"
    ],
    "forcedInclude": [],
    "defines": [],
    "compilerPath": "/usr/bin/gcc",
    "cStandard": "c17",
    "cppStandard": "c++98",
    "intelliSenseMode": "linux-gcc-x64",
    "compilerPathIsExplicit": true,
    "cStandardIsExplicit": true,
    "cppStandardIsExplicit": true,
    "intelliSenseModeIsExplicit": true,
    "compilerPathInCppPropertiesJson": "/usr/bin/gcc",
    "mergeConfigurations": false,
    "browse": {
        "path": [
            "/home/malvee/code/tetragon/bpf/**",
            "/home/malvee/code/tetragon/bpf/include",
            "${workspaceFolder}"
        ],
        "limitSymbolsToIncludedHeaders": true
    }
}
Modified Settings:
{
    "C_Cpp.errorSquiggles": "enabled",
    "C_Cpp.default.compilerPath": "/usr/bin/gcc"
}
Additional Tracked Settings:
{
    "editorTabSize": 2,
    "editorInsertSpaces": true,
    "editorAutoClosingBrackets": "languageDefined",
    "filesEncoding": "utf8",
    "filesAssociations": {
        "*.css": "tailwindcss"
    },
    "filesExclude": {
        "**/.git": true,
        "**/.svn": true,
        "**/.hg": true,
        "**/.DS_Store": true,
        "**/Thumbs.db": true
    },
    "filesAutoSaveAfterDelay": false,
    "editorInlayHintsEnabled": true,
    "editorParameterHintsEnabled": true,
    "searchExclude": {
        "**/node_modules": true,
        "**/bower_components": true,
        "**/*.code-search": true
    },
    "workbenchSettingsEditor": "ui"
}
cpptools version (native): 1.23.6.0
Current database path: /home/malvee/.cache/vscode-cpptools/584948c031d850a2bd45203b3ed0aa43/.browse.VC.db
Translation Unit Mappings:
[ /home/malvee/code/tetragon/bpf/process/bpf_enforcer.c - source TU]:
    /home/malvee/code/tetragon/bpf/process/bpf_enforcer.h
Translation Unit Configurations:
[ /home/malvee/code/tetragon/bpf/process/bpf_enforcer.c ]
    Process ID: 83170
    Memory Usage: 18 MB
    Compiler Path: /usr/bin/gcc
    Includes:
        /home/malvee/code/tetragon/bpf/include
        /home/malvee/code/tetragon/bpf/lib
        /home/malvee/code/tetragon/bpf/libbpf
    System Includes:
        /usr/lib/gcc/x86_64-redhat-linux/14/include
        /usr/local/include
        /usr/include
    Standard Version: c17
    IntelliSense Mode: linux-gcc-x64
    Other Flags:
        --gcc
        --gnu_version=140201
Total Memory Usage: 18 MB

------- Workspace parsing diagnostics -------
Number of files discovered (not excluded): 24382

Other Extensions

No response

Additional context

No response

@0xMALVEE
Copy link
Author

0xMALVEE commented Apr 1, 2025

@sean-mcmanus

@sean-mcmanus
Copy link
Contributor

sean-mcmanus commented Apr 1, 2025

@0xMALVEE It doesn't repro for me. I'm not sure what could be causing the issue. The symptom can happen if the forced include cannot be found. We fixed a couple forced include bugs with 1.24.x, but it doesn't seem like you would be hitting one of those. You could set C_Cpp.loggingLevel to "Debug" and check the "C/C++" logging for any errors, but I'm not sure if you would see anything useful.

For some unknown reason, the forced include is not being used by the IntelliSense configuration.

@sean-mcmanus sean-mcmanus added Language Service not reproing We're not able to reproduce the issue (it's unlikely to get fixed until we find one). Feature: Configuration An issue related to configuring the extension or IntelliSense labels Apr 1, 2025
@sean-mcmanus
Copy link
Contributor

@0xMALVEE Your C/C++: Log Diagnostics logging has the forced include commented out -- can you provide the logging with it not commented out?

@sean-mcmanus sean-mcmanus removed the not reproing We're not able to reproduce the issue (it's unlikely to get fixed until we find one). label Apr 1, 2025
@sean-mcmanus
Copy link
Contributor

@0xMALVEE Okay, sorry, I misunderstood your post. It seems there is some problem without the forced include...

@bobbrow
Copy link
Member

bobbrow commented Apr 1, 2025

As far as I can tell, type_mapper.h isn't included by any other file in that repo, so forced include is required for it. You shouldn't need to force include everything, but unless you have a #include <type_mapper.h> somewhere in the code, IntelliSense isn't going to automatically know you want to use it.

@githubxone
Copy link

I also have a similar problem when using WSL:

Image

Image

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature: Configuration An issue related to configuring the extension or IntelliSense Language Service
Projects
Status: No status
Development

No branches or pull requests

4 participants