microsoft / microsoft/vscode-cpptools

rename of typedef'd struct doesn't work properly with unnamed structs

Open
#14,162 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug Feature: Find All References Feature: Rename Language Service Works in VS
Dominant language
TypeScript
Stars
6.2k
Forks
1.7k
Avg merge
14h 46m
Merged PRs (30d)
61

Description

Environment
  • OS and Version: W10 22H2
  • VS Code Version: 1.108.2
  • C/C++ Extension Version: 1.30.3
  • If using SSH remote, specify OS of remote machine: no
Bug Summary and Steps to Reproduce

Bug Summary:

If you don't name the struct in a typedef, i.e.

typedef struct {
    int a;
} type_t;

renaming the type (here: type_t) does list all references * as NOT A REFERENCE and with the checkbox not ticked.

* EDIT: If you define multiple variables and you rename the type there, it does detect the other variables as references, but not the typedef itself. If renaming at the typedef, none of the variables are references.

Image

When giving it a name, i.e.

typedef struct foo_s {
    int a;
} type_t;

the rename goes through immediately.

Image

EDIT2: This also affects renaming the fields of the struct.

Steps to reproduce:

  1. Make file main.c with:
typedef struct {
    int a;
} type_t;

type_t x;

int main() {
  return 0;
}
  1. Rename Symbol type_t
  2. Depending on where you trigger the rename (typedef or variable definition) the other one is NOT A REFERENCE
  3. Give the type any name
  4. Rename Symbol
  5. Now it magically is a reference ...

Expected behavior:
Rename works the same in both cases without saying it's NOT A REFERENCE when unnamed.


I mean, it isn't a huge problem, but having to tick the boxes each time because it doesn't detect that it's in fact a reference gets annoying.

But I'm happy that renaming macros finally works 😁

Configuration and Logs
This is basically the default configuration for gcc, but there you go:

[c_cpp_properties.json]
{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceFolder}/**"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "windowsSdkVersion": "10.0.26100.0",
            "compilerPath": "C:/Program Files/mingw64/bin/gcc.exe",
            "cppStandard": "c++03",
            "intelliSenseMode": "windows-gcc-x64",
            "cStandard": "c99"
        }
    ],
    "version": 4
}



[C/C++: Log Diagnostics]
-------- Diagnostics - 2/3/2026, 11:00:26 AM
Version: 1.30.3
Current Configuration:
{
    "name": "Win32",
    "includePath": [
        "d:/Syncbox/test/c-test/**"
    ],
    "defines": [
        "_DEBUG",
        "UNICODE",
        "_UNICODE"
    ],
    "windowsSdkVersion": "10.0.26100.0",
    "compilerPath": "C:/Program Files/mingw64/bin/gcc.exe",
    "cppStandard": "c++03",
    "intelliSenseMode": "windows-gcc-x64",
    "cStandard": "c99",
    "compilerPathIsExplicit": true,
    "cStandardIsExplicit": true,
    "cppStandardIsExplicit": true,
    "intelliSenseModeIsExplicit": true,
    "recursiveIncludesReduceIsExplicit": false,
    "recursiveIncludesPriorityIsExplicit": false,
    "recursiveIncludesOrderIsExplicit": false,
    "compilerPathInCppPropertiesJson": "C:/Program Files/mingw64/bin/gcc.exe",
    "mergeConfigurations": false,
    "recursiveIncludes": {},
    "browse": {
        "limitSymbolsToIncludedHeaders": true
    }
}
Modified Settings:
{
    "C_Cpp.inlayHints.parameterNames.enabled": true,
    "C_Cpp.inlayHints.parameterNames.suppressWhenArgumentContainsName": false,
    "C_Cpp.inlayHints.referenceOperator.enabled": true,
    "C_Cpp.errorSquiggles": "enabled",
    "C_Cpp.default.cStandard": "c99",
    "C_Cpp.vcFormat.indent.caseLabels": true,
    "C_Cpp.vcFormat.newLine.beforeCatch": false,
    "C_Cpp.vcFormat.newLine.beforeElse": false,
    "C_Cpp.commentContinuationPatterns": [
        {
            "begin": "/**",
            "continue": "*"
        }
    ],
    "C_Cpp.experimentalFeatures": "enabled"
}
Additional Tracked Settings:
{
    "editorTabSize": 4,
    "editorInsertSpaces": true,
    "editorAutoClosingBrackets": "languageDefined",
    "filesEncoding": "utf8",
    "filesAssociations": {
        "*.njs": "javascript",
        "*.cps": "javascript",
        "*.scr": "freebasic",
        "*.FCMacro": "python"
    },
    "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.30.2.0
Current database path: C:\USERS\ANDREAS\APPDATA\LOCAL\MICROSOFT\VSCODE-CPPTOOLS\4D947C8EF103797001BE961BE2B4AFE0\.BROWSE.VC.DB
Translation Unit Mappings:
[ D:\Syncbox\test\c-test\main.c - source TU]:
Translation Unit Configurations:
[ D:\Syncbox\test\c-test\main.c ]
    Process ID: 11472
    Memory Usage: 52 MB
    Compiler Path: C:\Program Files\mingw64\bin\gcc.exe
    Include paths:
        system include: C:\Program Files\mingw64\lib\gcc\x86_64-w64-mingw32\15.1.0\include
        system include: C:\Program Files\mingw64\include
        system include: C:\Program Files\mingw64\lib\gcc\x86_64-w64-mingw32\15.1.0\include-fixed
        system include: C:\Program Files\mingw64\x86_64-w64-mingw32\include
    Defines:
        _DEBUG
        UNICODE
        _UNICODE
    Standard Version: c99
    IntelliSense Mode: windows-gcc-x64
    Other Flags:
        --gcc
        --gnu_version=150100
Total Memory Usage: 52 MB

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



[the language server logging]
LSP: (received) cpptools/rename: file:///d%3A/Syncbox/test/c-test/main.c (id: 503)
LSP: (invoked) cpptools/rename: file:///d%3A/Syncbox/test/c-test/main.c (id: 503)
LSP: (received) textDocument/documentHighlight: file:///d%3A/Syncbox/test/c-test/main.c (id: 504)
LSP: (invoked) textDocument/documentHighlight: file:///d%3A/Syncbox/test/c-test/main.c (id: 504)
LSP: Sending response (id: 504)
LSP: Sending response (id: 503)
LSP: (received) cpptools/didChangeVisibleTextEditors
LSP: (invoked) cpptools/didChangeVisibleTextEditors
LSP: (received) textDocument/didChange: file:///d%3A/Syncbox/test/c-test/main.c
LSP: (invoked) textDocument/didChange: file:///d%3A/Syncbox/test/c-test/main.c
LSP: (received) cpptools/didChangeTextEditorSelection
LSP: (invoked) cpptools/didChangeTextEditorSelection
LSP: (received) cpptools/didChangeVisibleTextEditors
LSP: (invoked) cpptools/didChangeVisibleTextEditors
LSP: (received) cpptools/getFoldingRanges: file:///d%3A/Syncbox/test/c-test/main.c (id: 505)
LSP: (invoked) cpptools/getFoldingRanges: file:///d%3A/Syncbox/test/c-test/main.c (id: 505)
LSP: Sending response (id: 505)
LSP: (received) cpptools/getCodeActions: file:///d%3A/Syncbox/test/c-test/main.c (id: 506)
LSP: (invoked) cpptools/getCodeActions: file:///d%3A/Syncbox/test/c-test/main.c (id: 506)
LSP: Sending response (id: 506)
LSP: (received) cpptools/getDocumentSymbols: file:///d%3A/Syncbox/test/c-test/main.c (id: 507)
LSP: (invoked) cpptools/getDocumentSymbols: file:///d%3A/Syncbox/test/c-test/main.c (id: 507)
tag parsing file: D:\Syncbox\test\c-test\main.c
LSP: Sending response (id: 507)
Intellisense update pending for: file:///d%3A/Syncbox/test/c-test/main.c
IntelliSense update scheduled and TU acquisition started for: file:///d%3A/Syncbox/test/c-test/main.c
Update IntelliSense time (sec): 0.012
LSP: (received) cpptools/getFoldingRanges: file:///d%3A/Syncbox/test/c-test/main.c (id: 508)
LSP: (invoked) cpptools/getFoldingRanges: file:///d%3A/Syncbox/test/c-test/main.c (id: 508)
LSP: Sending response (id: 508)
Other Extensions

No response

Additional context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the main.c reproduction and inspect the cpptools/rename entry shown in the language-server log. Compare rename results for named and unnamed typedef structs, including struct fields; done means all relevant typedef, variable, and field references are detected consistently without manual checkbox selection.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.