Skip to content

Errors Related to Variable Definition Location and Colorization under WSL #11733

@mobsceneZ

Description

@mobsceneZ

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Language ServiceVisual StudioInherited from Visual Studiobugmore votes neededIssues that have been postponed until more community members upvote itverifiedBug has been reproduced

    Type

    No type

    Projects

    Status

    No status

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions