Skip to content

Regression in relative include path resolution since 1.23.6 #13606

Open
@l-inc

Description

@l-inc

Environment

  • OS and Version: Fedora 40 for x86_64
  • VS Code Version: 1.100.0 (also tested on 1.89.1)
  • C/C++ Extension Version: 1.25.3
  • If using SSH remote, specify OS of remote machine: not using SSH

Bug Summary and Steps to Reproduce

Bug Summary:
When a header file includes another header file relative to its own location but without the location of the including header file being listed in the include directories, the included header file is not found. This does not obey the search path order: "By default, the preprocessor looks for header files included by the quote form of the directive #include "file" first relative to the directory of the current file".

Steps to reproduce:

  1. Open the workspace file "bad-include.code-workspace" in the attached archive. Note that "my_compile_commands.json" assumes that the archive is unpacked into "/tmp/bad-include". Update this path as needed.

  2. Observe the errors as shown on the screenshot.

Configuration and Logs

-------- Diagnostics - 5/13/2025, 8:53:43 PM
Version: 1.25.3
Current Configuration:
{
    "name": "Linux",
    "includePath": [],
    "defines": [],
    "cppStandard": "gnu++17",
    "forcedInclude": [],
    "compileCommands": [
        "/tmp/bad-include/my_compile_commands.json"
    ],
    "cStandard": "gnu99",
    "intelliSenseMode": "linux-gcc-arm64",
    "intelliSenseModeIsExplicit": true,
    "cStandardIsExplicit": true,
    "cppStandardIsExplicit": false,
    "mergeConfigurations": false,
    "recursiveIncludes": {},
    "recursiveIncludesReduceIsExplicit": false,
    "recursiveIncludesPriorityIsExplicit": false,
    "recursiveIncludesOrderIsExplicit": false,
    "compilerPathIsExplicit": false,
    "browse": {
        "path": [
            "${workspaceFolder:bad}"
        ],
        "limitSymbolsToIncludedHeaders": true
    }
}
Modified Settings:
{
    "C_Cpp.errorSquiggles": "enabled",
    "C_Cpp.default.compileCommands": "${workspaceFolder:bad}/my_compile_commands.json",
    "C_Cpp.default.intelliSenseMode": "linux-gcc-arm64",
    "C_Cpp.default.compilerPath": "/usr/bin/aarch64-linux-gnu-gcc",
    "C_Cpp.default.cStandard": "gnu99",
    "C_Cpp.default.browse.path": [
        "${workspaceFolder:bad}"
    ],
    "C_Cpp.exclusionPolicy": "checkFilesAndFolders",
    "C_Cpp.doxygen.generatedStyle": "/*!",
    "C_Cpp.codeAnalysis.clangTidy.enabled": true,
    "C_Cpp.loggingLevel": "Debug"
}
Additional Tracked Settings:
{
    "editorTabSize": 4,
    "editorInsertSpaces": true,
    "editorAutoClosingBrackets": "languageDefined",
    "filesEncoding": "utf8",
    "filesAssociations": {
        "*.h": "c",
        "**/*.h": "c",
        "**/*.c": "c"
    },
    "filesExclude": {
        "**/.git": true,
        "**/.svn": true,
        "**/.hg": true,
        "**/.DS_Store": true,
        "**/Thumbs.db": true
    },
    "filesAutoSaveAfterDelay": true,
    "editorInlayHintsEnabled": true,
    "editorParameterHintsEnabled": true,
    "searchExclude": {
        "**/node_modules": true,
        "**/bower_components": true,
        "**/*.code-search": true
    },
    "workbenchSettingsEditor": "ui"
}
cpptools version (native): 1.25.3.0
Current database path: /home/l.inc/.cache/vscode-cpptools/35517b36843402bb46f108cb0c62b7ba/.browse.VC.db
Translation Unit Mappings:
[ /tmp/bad-include/main.c - source TU]:
Translation Unit Configurations:
[ /tmp/bad-include/main.c ]
    Process ID: 13046
    Memory Usage: 16 MB
    Compiler Path: /usr/bin/aarch64-linux-gnu-gcc
    Include paths:
        include (iquote): /tmp/bad-include
        include (iquote): /tmp/bad-include/include
        include (iquote): /tmp/bad-include/other
    Standard Version: c99
    IntelliSense Mode: linux-gcc-arm64
    Other Flags:
        --gcc
        --gnu_version=140200
    compile_commands.json entry:
        directory: /tmp/bad-include
        file: /tmp/bad-include/main.c
        arguments:
            /usr/bin/aarch64-linux-gnu-gcc
            -c
            -o
            main.o
            main.c
            -std=gnu99
            -ffreestanding
            -fno-builtin
            -fno-isolate-erroneous-paths-dereference
            -Wall
            -Wextra
            -Wno-main
            -Werror
            -nostdinc
            -nostdlib
            -O2
            -mabi=lp64
            -mgeneral-regs-only
            -iquote
            .
            -iquote
            include
            -iquote
            other
Total Memory Usage: 16 MB
Browse Paths from compile_commands.json, from workspace folder: /tmp/bad-include
    ${workspaceFolder:bad}
    /tmp/bad-include
    /tmp/bad-include/include
    /tmp/bad-include/other

------- Workspace parsing diagnostics -------
Number of files discovered (not excluded): 8
Number of files parsed: 6

Other Extensions

No response

Additional context

Here is a screenshot to demonstrate the problem (see the errors including "header4.h" and "header1.h":

Image

Note that the header files are successfully found and parsed when using C/C++ extension, version 1.23.6.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Feature: ConfigurationAn issue related to configuring the extension or IntelliSenseLanguage ServicebugregressionA bug that didn't exist in a previous release

    Type

    Projects

    Status

    No status

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions