microsoft / microsoft/vscode-cpptools

Comment tooltip not shown with variable defined though a preprocessor macro.

Open
#12,949 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug Feature: Doc comments 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: Windows 11
  • VS Code Version: 1.95.2
  • C/C++ Extension Version: 1.22.11
  • If using SSH remote, specify OS of remote machine: N/A
Bug Summary and Steps to Reproduce

Bug Summary: When defining variables using a preprocessor macro, the comment doesn't get shown in the tool tip.

Steps to reproduce:

#define SBIT(x) int x

/// @brief This comment is not shown
SBIT(foo);
/// @brief This comment is shown
int bar;

void main() {
  foo = 0;
  bar = 0;
}

Image
Image

Expected behavior:
It would be great if the comment for the macro based definition was viewable, which would help greatly when documenting register names and their function.

Configuration and Logs
c_cpp_properties.json

{
    "C_Cpp.default.compilerPath": "cl.exe"
}


-------- Diagnostics - 11/10/2024, 11:32:59 AM
Version: 1.22.11
Current Configuration:
{
    "name": "Win32",
    "includePath": [
        "c:/Users/haow6/Desktop/projects/Test/**"
    ],
    "defines": [
        "_DEBUG",
        "UNICODE",
        "_UNICODE"
    ],
    "windowsSdkVersion": "10.0.22621.0",
    "cStandard": "c17",
    "cppStandard": "c++17",
    "intelliSenseMode": "windows-msvc-x64",
    "intelliSenseModeIsExplicit": false,
    "cStandardIsExplicit": false,
    "cppStandardIsExplicit": false,
    "mergeConfigurations": false,
    "compilerPath": "cl.exe",
    "compilerPathIsExplicit": true,
    "browse": {
        "path": [
            "c:/Users/haow6/Desktop/projects/Test/**",
            "${workspaceFolder}"
        ],
        "limitSymbolsToIncludedHeaders": true
    }
}
Modified Settings:
{
    "C_Cpp.default.compilerPath": "cl.exe"
}
Additional Tracked Settings:
{
    "editorTabSize": 4,
    "editorInsertSpaces": true,
    "editorAutoClosingBrackets": "languageDefined",
    "filesEncoding": "utf8",
    "filesAssociations": {},
    "filesExclude": {
        "**/.git": true,
        "**/.svn": true,
        "**/.hg": true,
        "**/CVS": 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.22.11.0
Current database path: C:\USERS\HAOW6\APPDATA\LOCAL\MICROSOFT\VSCODE-CPPTOOLS\552EB1B157B66100E3B6FBE5D82B5329\.BROWSE.VC.DB
Translation Unit Mappings:
[ C:\Users\haow6\Desktop\projects\Test\main.c - source TU]:
Translation Unit Configurations:
[ C:\Users\haow6\Desktop\projects\Test\main.c ]
    Process ID: 32920
    Memory Usage: 58 MB
    Compiler Path: C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.40.33807\bin\Hostx64\x64\cl.exe
    Includes:
    System Includes:
        C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.40.33807\include
        C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um
        C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt
        C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared
        C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\winrt
        C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\cppwinrt
    Defines:
        _DEBUG
        UNICODE
        _UNICODE
    Standard Version: ms_c17
    IntelliSense Mode: windows-msvc-x64
Total Memory Usage: 58 MB

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


loggingLevel: Debug
LSP: (received) cpptools/initialize (id: 1)
LSP: (invoked) cpptools/initialize (id: 1)
cpptools version (TypeScript): 1.22.11
cpptools version (native): 1.22.11.0
Autocomplete is enabled.
Error squiggles are enabled if all header dependencies are resolved.
Hover is enabled.
IntelliSense Engine = default.
LSP: Sending response (id: 1)
LSP: (received) cpptools/queryCompilerDefaults (id: 2)
LSP: (invoked) cpptools/queryCompilerDefaults (id: 2)
Compiler info database not connected - skipping load.
Compiler info database not connected - skipping load.
LSP: Sending response (id: 2)
LSP: (received) cpptools/queryCompilerDefaults (id: 3)
LSP: (invoked) cpptools/queryCompilerDefaults (id: 3)
LSP: (received) cpptools/didChangeCppProperties (id: 4)
LSP: (received - deferred) textDocument/didOpen: file:///c%3A/Users/haow6/Desktop/projects/Test/main.c
Compiler info database not connected - skipping load.
LSP: (received - deferred) cpptools/didChangeVisibleTextEditors
LSP: (received - deferred) cpptools/getDocumentSymbols: file:///c%3A/Users/haow6/Desktop/projects/Test/main.c (id: 5)
LSP: (received - deferred) cpptools/getCodeActions: file:///c%3A/Users/haow6/Desktop/projects/Test/main.c (id: 6)
Compiler info database not connected - skipping load.
LSP: Sending response (id: 3)
LSP: (invoked) cpptools/didChangeCppProperties (id: 4)
Code browsing service initialized
Populating file name cache...
Attempting to get defaults from C++ compiler in "compilerPath" property: 'cl.exe'
Attempting to get defaults from C compiler in "compilerPath" property: 'cl.exe'
  Folder: C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2022\BUILDTOOLS\VC\TOOLS\MSVC\14.40.33807\INCLUDE\* will be indexed
  Folder: C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.22621.0\CPPWINRT\ will be indexed
  Folder: C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.22621.0\SHARED\ will be indexed
  Folder: C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.22621.0\UCRT\ will be indexed
  Folder: C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.22621.0\UM\ will be indexed
  Folder: C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.22621.0\WINRT\ will be indexed
  Folder: C:\USERS\HAOW6\DESKTOP\PROJECTS\TEST\ will be indexed
LSP: (queued) textDocument/didOpen: file:///c%3A/Users/haow6/Desktop/projects/Test/main.c
LSP: (queued) cpptools/didChangeVisibleTextEditors
LSP: (queued) cpptools/getDocumentSymbols: file:///c%3A/Users/haow6/Desktop/projects/Test/main.c (id: 5)
LSP: (queued) cpptools/getCodeActions: file:///c%3A/Users/haow6/Desktop/projects/Test/main.c (id: 6)
LSP: Sending response (id: 4)
LSP: (invoked) cpptools/getDocumentSymbols: file:///c%3A/Users/haow6/Desktop/projects/Test/main.c (id: 5)
Discovering files...
LSP: (invoked) textDocument/didOpen: file:///c%3A/Users/haow6/Desktop/projects/Test/main.c
LSP: (invoked) cpptools/didChangeVisibleTextEditors
LSP: Sending response (id: 5)
Intellisense update pending for: file:///c%3A/Users/haow6/Desktop/projects/Test/main.c
LSP: (invoked) cpptools/getCodeActions: file:///c%3A/Users/haow6/Desktop/projects/Test/main.c (id: 6)
LSP: Sending response (id: 6)
  Processing folder (recursive): C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.22621.0\SHARED\
  Processing folder (non-recursive): C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2022\BUILDTOOLS\VC\TOOLS\MSVC\14.40.33807\INCLUDE
  Processing folder (recursive): C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.22621.0\CPPWINRT\
  Processing folder (recursive): C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.22621.0\UCRT\
  Processing folder (recursive): C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.22621.0\UM\
  Processing folder (recursive): C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.22621.0\WINRT\
  Processing folder (recursive): C:\USERS\HAOW6\DESKTOP\PROJECTS\TEST\
  Discovering files: 4958 file(s) processed
  0 file(s) removed from database
Done discovering files.
Populating include completion cache.
Parsing remaining files...
  Parsing: 0 files(s) processed
Done parsing remaining files.
Done populating filename cache. Elapsed time: 103 ms
LSP: (received) cpptools/getFoldingRanges: file:///c%3A/Users/haow6/Desktop/projects/Test/main.c (id: 7)
LSP: (invoked) cpptools/getFoldingRanges: file:///c%3A/Users/haow6/Desktop/projects/Test/main.c (id: 7)
LSP: Sending response (id: 7)
IntelliSense update scheduled and TU acquisition started for: file:///c%3A/Users/haow6/Desktop/projects/Test/main.c
Resolving recursive includes...
Done resolving recursive includes.
sending compilation args for C:\Users\haow6\Desktop\projects\Test\main.c
  system include: C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2022\BUILDTOOLS\VC\TOOLS\MSVC\14.40.33807\INCLUDE
  system include: C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.22621.0\UM
  system include: C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.22621.0\UCRT
  system include: C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.22621.0\SHARED
  system include: C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.22621.0\WINRT
  system include: C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.22621.0\CPPWINRT
  define: _DEBUG
  define: UNICODE
  define: _UNICODE
  stdver: ms_c17
  intelliSenseMode: windows-msvc-x64
Update IntelliSense time (sec): 0.044
LSP: (received) cpptools/getFoldingRanges: file:///c%3A/Users/haow6/Desktop/projects/Test/main.c (id: 8)
LSP: (invoked) cpptools/getFoldingRanges: file:///c%3A/Users/haow6/Desktop/projects/Test/main.c (id: 8)
LSP: Sending response (id: 8)
LSP: (received) cpptools/didChangeVisibleTextEditors
LSP: (invoked) cpptools/didChangeVisibleTextEditors
LSP: (received) cpptools/didChangeVisibleTextEditors
LSP: (invoked) cpptools/didChangeVisibleTextEditors
Intellisense update pending for: file:///c%3A/Users/haow6/Desktop/projects/Test/main.c
LSP: (received) cpptools/didChangeActiveEditor: file:///c%3A/Users/haow6/Desktop/projects/Test/main.c
LSP: (invoked) cpptools/didChangeActiveEditor: file:///c%3A/Users/haow6/Desktop/projects/Test/main.c
LSP: (received) cpptools/getCodeActions: file:///c%3A/Users/haow6/Desktop/projects/Test/main.c (id: 9)
LSP: (received) cpptools/didChangeTextEditorSelection
LSP: (invoked) cpptools/getCodeActions: file:///c%3A/Users/haow6/Desktop/projects/Test/main.c (id: 9)
LSP: Sending response (id: 9)
LSP: (invoked) cpptools/didChangeTextEditorSelection
IntelliSense update scheduled and TU acquisition started for: file:///c%3A/Users/haow6/Desktop/projects/Test/main.c
Update IntelliSense time (sec): 0.002
LSP: (received) cpptools/getFoldingRanges: file:///c%3A/Users/haow6/Desktop/projects/Test/main.c (id: 10)
LSP: (invoked) cpptools/getFoldingRanges: file:///c%3A/Users/haow6/Desktop/projects/Test/main.c (id: 10)
LSP: Sending response (id: 10)
LSP: (received) cpptools/getCodeActions: file:///c%3A/Users/haow6/Desktop/projects/Test/main.c (id: 11)
LSP: (invoked) cpptools/getCodeActions: file:///c%3A/Users/haow6/Desktop/projects/Test/main.c (id: 11)
LSP: Sending response (id: 11)
LSP: (received) cpptools/getFoldingRanges: file:///c%3A/Users/haow6/Desktop/projects/Test/main.c (id: 12)
LSP: (invoked) cpptools/getFoldingRanges: file:///c%3A/Users/haow6/Desktop/projects/Test/main.c (id: 12)
LSP: Sending response (id: 12)
LSP: (received) cpptools/didChangeVisibleTextEditors
LSP: (invoked) cpptools/didChangeVisibleTextEditors
LSP: (received) cpptools/didChangeVisibleTextEditors
LSP: (invoked) cpptools/didChangeVisibleTextEditors
LSP: (received) cpptools/hover: file:///c%3A/Users/haow6/Desktop/projects/Test/main.c (id: 13)
LSP: (invoked) cpptools/hover: file:///c%3A/Users/haow6/Desktop/projects/Test/main.c (id: 13)
LSP: Sending response (id: 13)
LSP: (received) cpptools/hover: file:///c%3A/Users/haow6/Desktop/projects/Test/main.c (id: 14)
LSP: (invoked) cpptools/hover: file:///c%3A/Users/haow6/Desktop/projects/Test/main.c (id: 14)
LSP: Sending response (id: 14)
LSP: (received) cpptools/hover: file:///c%3A/Users/haow6/Desktop/projects/Test/main.c (id: 15)
LSP: (invoked) cpptools/hover: file:///c%3A/Users/haow6/Desktop/projects/Test/main.c (id: 15)
LSP: Sending response (id: 15)
Other Extensions

No other extensions were enabled.

Additional context

None.

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 by reproducing the example in main.c and inspect the cpptools/hover behavior for the macro-defined foo and direct bar symbols. Trace how IntelliSense associates comments with symbols, then verify that hovering over foo shows its comment while the existing bar tooltip remains correct.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, typescript
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.