Skip to content

Create declaration/definition doesn't work properly #13773

@bhubavenski

Description

@bhubavenski

Environment

  • OS and Version: Windows 11 Pro 24H2
  • VS Code Version: 1.102.1
  • C/C++ Extension Version: 1.26.3
  • If using SSH remote, specify OS of remote machine: x

Bug Summary and Steps to Reproduce

Trying to create two different definitions for functions with the same name in two different structs does not result in two separate definitions.
Instead, only one definition is created (for one of the functions), and when attempting to create a definition for the second function, VS Code reports that a definition already exists, even though it actually does not.

Steps to reproduce:

  1. Create inc1.h and inc2.h files
  2. Create
struct Struct1 {
    void print();
};

in inc1.h

and

struct Struct2 {
    void print();
};

in inc2.h

  1. try using the feature Create definition of print in inc1.cpp on Struct1::print()
  2. try using the feature Create definition of print in inc2.cpp on Struct2::print()

Expected behavior: to create two different definitions in two different file

Configuration and Logs

`c_cpp_properties.json`


{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "windowsSdkVersion": "10.0.26100.0",
            "cStandard": "c17",
            "cppStandard": "c++17",
            "intelliSenseMode": "windows-gcc-x64",
            "compilerPath": "C:/msys64/ucrt64/bin/g++.exe"
        }
    ],
    "version": 4
}


`C/C++: Log Diagnostics`


-------- Diagnostics - 7/21/2025, 1:44:02 PM
Version: 1.26.3
Current Configuration:
{
    "name": "Win32",
    "includePath": [],
    "defines": [
        "_DEBUG",
        "UNICODE",
        "_UNICODE"
    ],
    "windowsSdkVersion": "10.0.26100.0",
    "cStandard": "c17",
    "cppStandard": "c++17",
    "intelliSenseMode": "windows-gcc-x64",
    "compilerPath": "C:/msys64/ucrt64/bin/g++.exe",
    "compilerPathIsExplicit": true,
    "cStandardIsExplicit": true,
    "cppStandardIsExplicit": true,
    "intelliSenseModeIsExplicit": true,
    "recursiveIncludesReduceIsExplicit": false,
    "recursiveIncludesPriorityIsExplicit": false,
    "recursiveIncludesOrderIsExplicit": false,
    "compilerPathInCppPropertiesJson": "C:/msys64/ucrt64/bin/g++.exe",
    "mergeConfigurations": false,
    "recursiveIncludes": {},
    "browse": {
        "limitSymbolsToIncludedHeaders": true
    }
}
Modified Settings:
{
    "C_Cpp.errorSquiggles": "enabled",
    "C_Cpp.default.compilerPath": "c:\\MinGW\\bin\\g++.exe"
}
Additional Tracked Settings:
{
    "editorTabSize": 4,
    "editorInsertSpaces": true,
    "editorAutoClosingBrackets": "languageDefined",
    "filesEncoding": "utf8",
    "filesAssociations": {
        "type_traits": "cpp",
        "any": "cpp",
        "array": "cpp",
        "atomic": "cpp",
        "strstream": "cpp",
        "barrier": "cpp",
        "bit": "cpp",
        "bitset": "cpp",
        "cctype": "cpp",
        "cfenv": "cpp",
        "charconv": "cpp",
        "chrono": "cpp",
        "cinttypes": "cpp",
        "clocale": "cpp",
        "cmath": "cpp",
        "codecvt": "cpp",
        "compare": "cpp",
        "complex": "cpp",
        "concepts": "cpp",
        "condition_variable": "cpp",
        "coroutine": "cpp",
        "csetjmp": "cpp",
        "csignal": "cpp",
        "cstdarg": "cpp",
        "cstddef": "cpp",
        "cstdint": "cpp",
        "cstdio": "cpp",
        "cstdlib": "cpp",
        "cstring": "cpp",
        "ctime": "cpp",
        "cuchar": "cpp",
        "cwchar": "cpp",
        "cwctype": "cpp",
        "deque": "cpp",
        "forward_list": "cpp",
        "list": "cpp",
        "map": "cpp",
        "set": "cpp",
        "string": "cpp",
        "unordered_map": "cpp",
        "unordered_set": "cpp",
        "vector": "cpp",
        "exception": "cpp",
        "expected": "cpp",
        "algorithm": "cpp",
        "functional": "cpp",
        "iterator": "cpp",
        "memory": "cpp",
        "memory_resource": "cpp",
        "numeric": "cpp",
        "optional": "cpp",
        "random": "cpp",
        "ratio": "cpp",
        "regex": "cpp",
        "source_location": "cpp",
        "string_view": "cpp",
        "system_error": "cpp",
        "tuple": "cpp",
        "utility": "cpp",
        "flat_map": "cpp",
        "flat_set": "cpp",
        "format": "cpp",
        "fstream": "cpp",
        "future": "cpp",
        "generator": "cpp",
        "initializer_list": "cpp",
        "iomanip": "cpp",
        "iosfwd": "cpp",
        "iostream": "cpp",
        "istream": "cpp",
        "latch": "cpp",
        "limits": "cpp",
        "mutex": "cpp",
        "new": "cpp",
        "numbers": "cpp",
        "ostream": "cpp",
        "print": "cpp",
        "ranges": "cpp",
        "scoped_allocator": "cpp",
        "semaphore": "cpp",
        "shared_mutex": "cpp",
        "span": "cpp",
        "spanstream": "cpp",
        "sstream": "cpp",
        "stacktrace": "cpp",
        "stdexcept": "cpp",
        "stdfloat": "cpp",
        "stop_token": "cpp",
        "streambuf": "cpp",
        "syncstream": "cpp",
        "text_encoding": "cpp",
        "thread": "cpp",
        "typeindex": "cpp",
        "typeinfo": "cpp",
        "valarray": "cpp",
        "variant": "cpp",
        "*.inc": "cpp"
    },
    "filesExclude": {
        "**/.git": false,
        "**/.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.26.3.0
Current database path: C:\USERS\BOBKATA75\APPDATA\LOCAL\MICROSOFT\VSCODE-CPPTOOLS\4B72DE3F676C91E2036DFE26647D1FA8\.BROWSE.VC.DB
Translation Unit Mappings:
[ C:\Users\bobkata75\Desktop\primerren-cpp\inc1.cpp - source TU]:
[ C:\Users\bobkata75\Desktop\primerren-cpp\inc1.h - source TU]:
[ C:\Users\bobkata75\Desktop\primerren-cpp\inc2.h - source TU]:
[ C:\Users\bobkata75\Desktop\primerren-cpp\main.cpp - source TU]:
    C:\msys64\ucrt64\include\c++\15.1.0\bits\locale_facets.h
    C:\msys64\ucrt64\include\c++\15.1.0\ostream
    C:\msys64\ucrt64\include\c++\15.1.0\x86_64-w64-mingw32\bits\ctype_base.h
Translation Unit Configurations:
[ C:\Users\bobkata75\Desktop\primerren-cpp\inc1.cpp ]
    Process ID: 6192
    Memory Usage: 52 MB
    Compiler Path: C:\msys64\ucrt64\bin\g++.exe
    Include paths:
        system include: C:\msys64\ucrt64\include\c++\15.1.0
        system include: C:\msys64\ucrt64\include\c++\15.1.0\x86_64-w64-mingw32
        system include: C:\msys64\ucrt64\include\c++\15.1.0\backward
        system include: C:\msys64\ucrt64\lib\gcc\x86_64-w64-mingw32\15.1.0\include
        system include: C:\msys64\ucrt64\include
        system include: C:\msys64\ucrt64\lib\gcc\x86_64-w64-mingw32\15.1.0\include-fixed
    Defines:
        _DEBUG
        UNICODE
        _UNICODE
    Standard Version: c++17
    IntelliSense Mode: windows-gcc-x64
    Other Flags:
        --g++
        --gnu_version=150100
[ C:\Users\bobkata75\Desktop\primerren-cpp\inc1.h ]
    Process ID: 8612
    Memory Usage: 53 MB
    Compiler Path: C:\msys64\ucrt64\bin\g++.exe
    Include paths:
        system include: C:\msys64\ucrt64\include\c++\15.1.0
        system include: C:\msys64\ucrt64\include\c++\15.1.0\x86_64-w64-mingw32
        system include: C:\msys64\ucrt64\include\c++\15.1.0\backward
        system include: C:\msys64\ucrt64\lib\gcc\x86_64-w64-mingw32\15.1.0\include
        system include: C:\msys64\ucrt64\include
        system include: C:\msys64\ucrt64\lib\gcc\x86_64-w64-mingw32\15.1.0\include-fixed
    Defines:
        _DEBUG
        UNICODE
        _UNICODE
    Standard Version: c++17
    IntelliSense Mode: windows-gcc-x64
    Other Flags:
        --g++
        --gnu_version=150100
[ C:\Users\bobkata75\Desktop\primerren-cpp\inc2.h ]
    Process ID: 6204
    Memory Usage: 53 MB
    Compiler Path: C:\msys64\ucrt64\bin\g++.exe
    Include paths:
        system include: C:\msys64\ucrt64\include\c++\15.1.0
        system include: C:\msys64\ucrt64\include\c++\15.1.0\x86_64-w64-mingw32
        system include: C:\msys64\ucrt64\include\c++\15.1.0\backward
        system include: C:\msys64\ucrt64\lib\gcc\x86_64-w64-mingw32\15.1.0\include
        system include: C:\msys64\ucrt64\include
        system include: C:\msys64\ucrt64\lib\gcc\x86_64-w64-mingw32\15.1.0\include-fixed
    Defines:
        _DEBUG
        UNICODE
        _UNICODE
    Standard Version: c++17
    IntelliSense Mode: windows-gcc-x64
    Other Flags:
        --g++
        --gnu_version=150100
[ C:\Users\bobkata75\Desktop\primerren-cpp\main.cpp ]
    Process ID: 18788
    Memory Usage: 115 MB
    Compiler Path: C:\msys64\ucrt64\bin\g++.exe
    Include paths:
        system include: C:\msys64\ucrt64\include\c++\15.1.0
        system include: C:\msys64\ucrt64\include\c++\15.1.0\x86_64-w64-mingw32
        system include: C:\msys64\ucrt64\include\c++\15.1.0\backward
        system include: C:\msys64\ucrt64\lib\gcc\x86_64-w64-mingw32\15.1.0\include
        system include: C:\msys64\ucrt64\include
        system include: C:\msys64\ucrt64\lib\gcc\x86_64-w64-mingw32\15.1.0\include-fixed
    Defines:
        _DEBUG
        UNICODE
        _UNICODE
    Standard Version: c++17
    IntelliSense Mode: windows-gcc-x64
    Other Flags:
        --g++
        --gnu_version=150100
Total Memory Usage: 274 MB

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


`language server logging`


loggingLevel: 6
loggingLevel has changed to: Debug
Shutting down IntelliSense server: C:\Users\bobkata75\Desktop\primerren-cpp\inc1.cpp
LSP: (received) cpptools/didChangeCppProperties (id: 456)
LSP: (invoked) cpptools/didChangeCppProperties (id: 456)
Shutting down IntelliSense server: C:\Users\bobkata75\Desktop\primerren-cpp\inc1.h
Shutting down IntelliSense server: C:\Users\bobkata75\Desktop\primerren-cpp\inc2.h
Shutting down IntelliSense server: C:\Users\bobkata75\Desktop\primerren-cpp\main.cpp
  Folder: C:\MSYS64\UCRT64\INCLUDE will be indexed
  Folder: C:\MSYS64\UCRT64\LIB\GCC\X86_64-W64-MINGW32\15.1.0\INCLUDE will be indexed
  Folder: C:\MSYS64\UCRT64\LIB\GCC\X86_64-W64-MINGW32\15.1.0\INCLUDE-FIXED will be indexed
  Folder: C:\USERS\BOBKATA75\DESKTOP\PRIMERREN-CPP will be indexed
LSP: Sending response (id: 456)
loggingLevel has changed to: Warning
LSP: Message ignored due to no registered handler: $/setTrace
LSP: (received) cpptools/didChangeSettings
LSP: (invoked) cpptools/didChangeSettings
Autocomplete is enabled.
Error squiggles are enabled.
Hover is enabled.
IntelliSense Engine = default.
Enhanced Colorization is enabled.
loggingLevel has changed to: Debug
LSP: (received) cpptools/didChangeCppProperties (id: 458)
LSP: (invoked) cpptools/didChangeCppProperties (id: 458)
  Folder: C:\MSYS64\UCRT64\INCLUDE will be indexed
  Folder: C:\MSYS64\UCRT64\LIB\GCC\X86_64-W64-MINGW32\15.1.0\INCLUDE will be indexed
  Folder: C:\MSYS64\UCRT64\LIB\GCC\X86_64-W64-MINGW32\15.1.0\INCLUDE-FIXED will be indexed
  Folder: C:\USERS\BOBKATA75\DESKTOP\PRIMERREN-CPP will be indexed
LSP: Sending response (id: 458)
LSP: (received) cpptools/didChangeVisibleTextEditors
LSP: (invoked) cpptools/didChangeVisibleTextEditors
LSP: (received) cpptools/didChangeVisibleTextEditors
LSP: (invoked) cpptools/didChangeVisibleTextEditors

Other Extensions

No response

Additional context

No response

Metadata

Metadata

Assignees

Labels

Type

Projects

Status

No status

Relationships

None yet

Development

No branches or pull requests

Issue actions