microsoft / vscode-cpptools

Official repository for the Microsoft C/C++ extension for VS Code.
Other
5.52k stars 1.55k forks source link

IntelliSense cannot find structure member references #12799

Open al20878 opened 3 weeks ago

al20878 commented 3 weeks ago

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

sean-mcmanus commented 3 weeks ago

@al20878 This appears to be a duplicate of https://github.com/microsoft/vscode-cpptools/issues/11464

sean-mcmanus commented 3 weeks ago

@al20878 Ignore my previous comment (that issue is with the CDD feature). I've filed a bug on VS at https://developercommunity.visualstudio.com/t/CC-IntelliSense-operations-dont-work/10760638 , but they may resolve it as a duplicate of another issue, because I think it's a known issue.