microsoft / microsoft/vscode-cpptools

Errors Related to Variable Definition Location and Colorization under WSL

Open
#11,733 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug Language Service more votes needed verified Visual Studio
Dominant language
TypeScript
Stars
6.2k
Forks
1.7k
Avg merge
14h 46m
Merged PRs (30d)
61

Description

Environment
  • OS and Version: Windows 10 22H2 19045.3693
  • VS Code Version: 1.84.2 (commit 1a5daa3a0231a0fbba4f14db7ec463cf99d7768e)
  • C/C++ Extension Version: v1.18.5
  • If using SSH remote, specify OS of remote machine: WSL Ubuntu 20.04 (5.10.16.3-microsoft-standard-WSL2)
Bug Summary and Steps to Reproduce

Bug Summary:

  1. Some variables defined in the code body of a C Macros are not colorized but others are.
  2. When clicking 'Go to Definition' on variables defined within the C Macros, it shows No definition found.

Steps to reproduce:

  1. Start up WSL in Windows Terminal, create a directory named issue;
  2. Open this directory in VSCode by switching to it and typing code .;
  3. Create a new file name poc.c, and copy following content:
#include <time.h>
#include <stdio.h>
#include <stdlib.h>

#define NOP(block)      \
    do {                \
        {block}         \
    } while (0);

typedef struct {
    int a;
    double b;
} test;

int main(void) {
    NOP({
        test v1;
        v1.a = 10; 

        for (int i = 0; i < 10; i++) {
            if (rand() % 2) {
                test v2;
            }
        }
    })
}
  1. See the first bug:
    捕获
  2. See the second bug:
    捕获

Expected behavior:

  1. At least all the type keywords of variables are colorized;
  2. 'Go to Definition' points to the correct variable definition location;
Configuration and Logs
{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/**"
            ],
            "defines": [],
            "compilerPath": "/usr/local/bin/clang",
            "cStandard": "c17",
            "cppStandard": "c++14",
            "intelliSenseMode": "linux-clang-x64"
        }
    ],
    "version": 4
}

-------- Diagnostics - 11/22/2023, 9:04:19 PM
Version: 1.18.5
Current Configuration:
{
    "name": "Linux",
    "includePath": [
        "/home/lain/issue/**"
    ],
    "defines": [],
    "compilerPath": "/usr/local/bin/clang",
    "cStandard": "c17",
    "cppStandard": "c++14",
    "intelliSenseMode": "linux-clang-x64",
    "compilerPathIsExplicit": true,
    "cStandardIsExplicit": true,
    "cppStandardIsExplicit": true,
    "intelliSenseModeIsExplicit": true,
    "compilerPathInCppPropertiesJson": "/usr/local/bin/clang",
    "mergeConfigurations": false,
    "browse": {
        "path": [
            "/home/lain/issue/**",
            "${workspaceFolder}"
        ],
        "limitSymbolsToIncludedHeaders": true
    }
}
cpptools version (native): 1.18.3.0
Translation Unit Mappings:
[ /home/lain/issue/poc.c ]:
    /home/lain/issue/poc.c
Translation Unit Configurations:
[ /home/lain/issue/poc.c ]:
    Process ID: 13842
    Memory Usage: 11 MB
    Compiler Path: /usr/local/bin/clang
    Includes:
        /home/lain/.wasmedge/include
        /usr/local/lib/clang/13.0.0/include
        /usr/local/include
        /usr/include/x86_64-linux-gnu
        /usr/include
    Standard Version: c17
    IntelliSense Mode: linux-clang-x64
    Other Flags:
        --clang
        --clang_version=130000
Total Memory Usage: 11 MB

------- Workspace parsing diagnostics -------
Number of files discovered (not excluded): 23534
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

Reproduce the issue in poc.c under WSL using the supplied C/C++ configuration, then trace the extension's handling of variables inside the NOP C macro. Verify both syntax colorization and Go to Definition for v1, v1.a, i, and v2; done means the expected variable types are colorized and definitions resolve correctly.

Written by the indexing model from the issue text.

Assessment

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