microsoft / microsoft/vscode-cpptools

IntelliSense cannot find structure member references

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

Nobody has claimed this yet.

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

Description

Environment

Latest everything:

Version: 1.93.1 (system setup)
Commit: 38c31bc77e0dd6ae88a4e9cc93428cc27a56ba40
Date: 2024-09-11T17:20:05.685Z
Electron: 30.4.0
ElectronBuildId: 10073054
Chromium: 124.0.6367.243
Node.js: 20.15.1
V8: 12.4.254.20-electron.0
OS: Windows_NT x64 10.0.19045
Bug Summary and Steps to Reproduce

Consider the following code (test.c):

#include <stdio.h>
#include <stdlib.h>

typedef unsigned int   uint4;
typedef   signed int    int4;
typedef unsigned short uint2;
typedef   signed short  int2;
typedef unsigned char  uint1;
typedef   signed char   int1;

#if defined(_MSC_VER)
#  define PACKED(...)                           \
    __pragma(pack(push, 1))                     \
    __VA_ARGS__                                 \
    __pragma(pack(pop))
#else
#  if defined(__GNUC__)
#    define PACKED(...)                         \
    __VA_ARGS__                                 \
    __attribute__((packed))
#  endif
#endif

PACKED(struct S_newstruct {
    uint1   member1;
    uint2   member2[2];
    uint4   sys$member3;
    uint4   sys$member4[2];
});

int main(void)
{
    struct S_newstruct* s = malloc(sizeof(*s));
    printf("%u\n", s->member1);
    return 0;
}

If you try to "Go to references" while on member1 in the definition of structure S_newstruct, you'll get "No references found", not even that in the printf() statement in main(). That's very unexpected, and makes IntelliSense basically useless.

Configuration and Logs
$ cat .vscode/c_cpp_properties.json
{
    "configurations": [
        {
            "name": "Win32",
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE",
                "_GNU_SOURCE=1",
                "__CYGWIN__"
            ],
            "compilerPath": "C:/cygwin64/bin/gcc.exe",
            "compilerArgs": [ "-fms-extensions" ],
            "cStandard": "c17",
            "cppStandard": "c++17"
        }
    ],
    "version": 4
}
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 missing reference result using test.c and the configuration in .vscode/c_cpp_properties.json, with the Cygwin compiler settings shown. Start from the IntelliSense "Go to references" entry point for the member1 definition. Done means references from the structure definition include the member1 use in main().

Written by the indexing model from the issue text.

Assessment

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