vscode-cpptools icon indicating copy to clipboard operation
vscode-cpptools copied to clipboard

Typing C struct declarations with explicit "struct" keyword doesn't trigger autocomplete

Open RigoLigoRLC opened this issue 6 months ago • 1 comments

Environment

  • OS and Version: macOS 15.5 (24F74)
  • VS Code Version: Version: 1.100.2 (Universal) 848b80aeb52026648a8ff9f7c45a9b0a80641e2e
  • C/C++ Extension Version: 1.25.3
  • If using SSH remote, specify OS of remote machine: N/A

Bug Summary and Steps to Reproduce

Bug Summary:

When typing a C struct declaration that requires an explicit "struct" keyword in function parameters, autocomplete candidate box does not appear. Image

When you just use the struct's name it works fine but the language server won't fix your missing "struct" keyword still. Image

The workspace in which I found this issue is OpenOCD project, single project configured with Autoconf, and compile_commands.json generated from bear was used.

Steps to reproduce:

  1. Define a C struct (like struct foo {};).
  2. In a function body or function parameters, type "struct": right now it still pops autocomplete candidate box
  3. Press Spacebar, and type struct name (like "foo"). No autocomplete candidate box popping. Expected behavior: Autocomplete should be triggered.

Configuration and Logs

*No c_cpp_properties.json is used in the project; was using compile_commands.json*

C/C++: Log Diagnostics:

-------- Diagnostics - 2025/5/23 20:13:03
Version: 1.25.3
Current Configuration:
{
    "name": "Mac",
    "includePath": [
        "/Volumes/Extern/contrib/openocd/**"
    ],
    "compilerPath": "/usr/bin/clang",
    "cStandard": "c17",
    "cppStandard": "c++17",
    "intelliSenseMode": "macos-clang-arm64",
    "compilerPathInCppPropertiesJson": "/usr/bin/clang",
    "defines": [
        "HAVE_NO_AUTOCONF=1"
    ],
    "intelliSenseModeIsExplicit": false,
    "cStandardIsExplicit": false,
    "cppStandardIsExplicit": false,
    "mergeConfigurations": false,
    "recursiveIncludes": {},
    "recursiveIncludesReduceIsExplicit": false,
    "recursiveIncludesPriorityIsExplicit": false,
    "recursiveIncludesOrderIsExplicit": false,
    "compilerPathIsExplicit": false,
    "browse": {
        "limitSymbolsToIncludedHeaders": true
    }
}
Modified Settings:
{
    "C_Cpp.default.defines": [
        "HAVE_NO_AUTOCONF=1"
    ],
    "C_Cpp.intelliSenseCachePath": "/Volumes/Extern/MSCppCache/"
}
Additional Tracked Settings:
{
    "editorTabSize": 8,
    "editorInsertSpaces": false,
    "editorAutoClosingBrackets": "languageDefined",
    "filesEncoding": "utf8",
    "filesAssociations": {
        "jim-nvp.h": "c",
        "jim.h": "c",
        "jim-win32compat.h": "c",
        "config.h": "c",
        "loongarch_ejtag.h": "c"
    },
    "filesExclude": {
        "**/.git": true,
        "**/.svn": true,
        "**/.hg": true,
        "**/.DS_Store": true,
        "**/Thumbs.db": true
    },
    "filesAutoSaveAfterDelay": false,
    "editorInlayHintsEnabled": false,
    "editorParameterHintsEnabled": true,
    "searchExclude": {
        "**/node_modules": true,
        "**/bower_components": true,
        "**/*.code-search": true
    },
    "workbenchSettingsEditor": "ui"
}
cpptools version (native): 1.25.3.0
Current database path: /Users/rigoligo/Library/Caches/vscode-cpptools/f8f55d5d314dc735e4b2500e975937a5/.browse.VC.db
Translation Unit Mappings:
[ /Volumes/Extern/contrib/openocd/src/target/loongarch/loongarch_ejtag.c - source TU]:
    /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/_ctype.h
    /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/_stdlib.h
    /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/_string.h
    /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/_strings.h
    /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/_time.h
    /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/_types/_uint16_t.h
    /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/_types/_uint32_t.h
    /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/mach/arm/_structs.h
    /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types/_id_t.h
    /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types/_off_t.h
    /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types/_u_int16_t.h
    /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types/_uid_t.h
    /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/resource.h
    /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/signal.h
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/16/include/stdarg.h
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/16/include/stddef.h
    /Volumes/Extern/contrib/openocd/src/target/loongarch/loongarch_ejtag.h
[ /Volumes/Extern/contrib/openocd/src/target/mips_ejtag.c - source TU]:
    /Volumes/Extern/contrib/openocd/jimtcl/jim.h
    /Volumes/Extern/contrib/openocd/src/helper/binarybuffer.h
    /Volumes/Extern/contrib/openocd/src/jtag/commands.h
    /Volumes/Extern/contrib/openocd/src/jtag/jtag.h
    /Volumes/Extern/contrib/openocd/src/target/mips_ejtag.h
Translation Unit Configurations:
[ /Volumes/Extern/contrib/openocd/src/target/loongarch/loongarch_ejtag.c ]
    Process ID: 53375
    Memory Usage: 51 MB
    Compiler Path: /usr/bin/clang
    Include paths:
        system include: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/16/include
        system include: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include
        system include: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
        system framework search path (default): /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks
        include (recursive): /Volumes/Extern/contrib/openocd/src
        include (recursive): /Volumes/Extern/contrib/openocd
        include (recursive): /Volumes/Extern/contrib/openocd/jimtcl
        include (recursive): /Volumes/Extern/contrib/openocd/contrib/firmware/angie/c/include
    Defines:
        HAVE_NO_AUTOCONF=1
    Standard Version: c17
    IntelliSense Mode: macos-clang-arm64
    Other Flags:
        --clang
        --clang_version=170006
[ /Volumes/Extern/contrib/openocd/src/target/mips_ejtag.c ]
    Process ID: 53373
    Memory Usage: 32 MB
    Compiler Path: /usr/bin/clang
    Include paths:
        system include: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/16/include
        system include: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include
        system include: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
        system framework search path (default): /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks
        include (recursive): /Volumes/Extern/contrib/openocd
        include (recursive): /Volumes/Extern/contrib/openocd/src
        include (recursive): /Volumes/Extern/contrib/openocd/jimtcl
        include (recursive): /Volumes/Extern/contrib/openocd/contrib/firmware/angie/c/include
    Defines:
        HAVE_NO_AUTOCONF=1
    Standard Version: c17
    IntelliSense Mode: macos-clang-arm64
    Other Flags:
        --clang
        --clang_version=170006
Total Memory Usage: 84 MB

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

------- Potential include path issues --------
Some headers exist in multiple locations. If IntelliSense is behaving incorrectly,
try adding one of the alternate paths to the "includePath" in your configuration in
c_cpp_properties.json to override the automatic path discovery for that header.

Using: /Volumes/Extern/contrib/openocd/config.h
    Alternative: "/Volumes/Extern/contrib/openocd/src/jtag/drivers/libjaylink"
Using: /Volumes/Extern/contrib/openocd/contrib/firmware/angie/c/include/io.h
    Alternative: "/Volumes/Extern/contrib/openocd/src/jtag/drivers/OpenULINK/include"


LS Logs: See "Additional Context", it doesn't fit into this field

Other Extensions

No response

Additional context

Video: https://github.com/user-attachments/assets/b77a8d79-6efa-44fc-a048-4b84c542054c

LSP Log: lsp_log.log

RigoLigoRLC avatar May 23 '25 12:05 RigoLigoRLC

@RigoLigoRLC You can use Ctrl+Space to force the completion to appear as a workaround, although any intermediate text will also appear in the completion list as a symbol.

Image

sean-mcmanus avatar May 27 '25 23:05 sean-mcmanus

@sean-mcmanus The CTRL + space doesn't work either.

brianignacio5 avatar Oct 22 '25 02:10 brianignacio5

Hi, has the issue seen any progress recently ?

Magyar57 avatar Dec 01 '25 23:12 Magyar57

@Magyar57 No. However, I was unable to find a VS issue tracking it so I filed https://developercommunity.visualstudio.com/t/CC-completion-doesnt-automatically-w/11009010 .

sean-mcmanus avatar Dec 02 '25 00:12 sean-mcmanus

@brianignacio5 Ctrl+Space works for me, i.e. manually invoking completion. Are you able to provide more repro info?

sean-mcmanus avatar Dec 02 '25 00:12 sean-mcmanus

Not talking in Brian's name, but I found why Ctrl+Space doesn't bring up the completion: I have both "Trigger Suggest" and "Trigger Parameter Hints" bound to Ctrl+Space ; if I reset the "Trigger Parameter Hints" shortcut back to Ctrl+Backspace then the "Trigger Suggest" works. It is not a very good solution though, as I'm used to triggering parameter hints with Ctrl+Space

Magyar57 avatar Dec 02 '25 09:12 Magyar57

Well it works, but a bit sloppily: sometimes it shows a handful of suggestions, sometimes simply show No suggestions. ; I couldn't identify when or why this happens

Magyar57 avatar Dec 02 '25 09:12 Magyar57