-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IntelliSense not working correctly with anonymous members #6412
Comments
What compiler are you using? I'm not able to get the code below to compile with gcc 10.2 or clang 11 (with -std=c++17 -fms-extensions). What code are you using that compiles?
|
I tried with gcc 10 and 9, clang gives a warning about MS extensions but still compiles. It seams to works since quite some time. |
Oops, yeah, I was using C++ instead of C. |
Mhh, looks like I did a bit too far in my intention to reduce to the minimal sample. typedef struct S1_s {
int i1;
char c1;
} S1_t;
struct S2 {
S1_t;
int i2;
char c2;
}; The absence of
struct S2 {
struct S1_t; // Not valid C
};
struct S2 {
struct S1_s; // Works as expected, struct is specified and actual struct name is used, not the typedef
};
struct S2 {
S1_t; // Compiles with MS extensions, not recognized by the VS parser.
}; |
I've filed a bug on the crash on our shared VS parser at https://developercommunity.visualstudio.com/content/problem/1241877/c-intellisense-process-crashes-after-invoking-comp.html ; however, I'm not understanding the "no crash" repro for the |
Tanks for the feedback! |
I'm experiencing this very same kind of an issue with freshly upgraded VS Code, as the OP reported.
makes intellisense mark all references to S1's members within S2 as "undefined": I set my C standard to c17 (used to be c11, but it makes no difference) in the settings...
|
The fix is available with https://github.com/microsoft/vscode-cpptools/releases/tag/1.7.0-insiders2 |
It was closed but it still does not work correctly. This is the program:
VS Code is fresh, 1.61 on Windows. Compiler is configured to be
Then these appear as "Problems":
Note that when the compiler task is run, the program compiles without any errors (there's only a warning that s2 is not used). Can this please be really fixed? |
Local (i.e. from the
local
P.S. Adding |
Hi @al20878 . Thanks for pointing this out. There are multiple issues here. The crash issue has been fixed. But, you are correct, there is still an issue where not all members are available for completion. I've reopened the issue against VS internally. |
We're tracing the issue where not all members are available for completion here: https://developercommunity.visualstudio.com/t/CPP-file-shows-incorrect-member-list-o/1565421. Thank you for the report! |
Hi, I saw the issue mentioned by @merlynomsft has been marked as resolved. Feel free to upvote so the issue can be reopened. |
Hi @al20878 . It looks like the issue here is that the C/C++ extension does not automatically enable MS extensions for Cygwin's gcc. Apparently (based solely on trying some MS extensions), Cygwin's gcc will enable MS extensions by default, despite not outputting the (required) define associated with that behavior: I'm able to work around that issue, and resolve IntelliSense squiggles with the repro code, by specifying the following in
It's by-design that using Cygwin's gcc will result in changing the IntelliSense mode to linux. Cygwin's gcc returns the define You might consider installing MinGW. It can be installed within Cygwin, separately, or as part of MSYS2. MinGW is a better option if targeting Windows natively. I believe the original problem this issue was tracking (the crash) has been resolved. I opened another issue for what remains: #8353 |
Type: LanguageService
IntelliSense not handling anonymous union member with named unions.
Generic information
Ubuntu 20.04
1.51.0-insiders
1.1.0-insiders3
Details of the issue
In the code sample [1] the IntelliSense recognize correctly the member
i2
andc2
but neitheri1
norc1
.[1]
This seems linked to C11 standard as well as MS extensions that both allow anonymous unions and struct in C.
Nonetheless, setting the language version to C11 does not change anything.
I tried adding
-fms-extensions
to either the "compilerPath" or the "compilerArgs" as suggested in #3063 which is suppose to be supported with by the cpptools since version0.22.2-insiders
. But this causes the language server to crash with the error code:Failed to read response from server: 8
.Note: when using completely anonymous struct (eg. code sample [2]) there is no issue at all.
[2]
However, as soon as a name is given to the internal member (eg. code sample [3]), the error reappears.
[3]
Note 2: somehow,
gdb
has the same kind of behavior of not being able to directly accessS2::i2
with code sample [1] but does allow direct access to those member with bother code [2] and [3]. The integrated debugger logically follows the same behavior.PS: For some reason, adding the
-fms-extensions
to compilerArgs may sometime enable the intelliSense to recognize theS2
members on hover but still fails to autocomplete and produce the same error message one the console.The text was updated successfully, but these errors were encountered: