Community
Participate
Working Groups
Overview: CDT indexer can't find the reference of MS-style anonymous struct's member Steps to Reproduce: 1) C Code: struct A { int a; }; struct B { struct A; int b; }; int main() { struct B b_struct; printf("%d",b_struct.a); // i m using gcc 4.5 ,show if i added the flag -fms-extensions,it can compile and run // but the CDT indexer show error : Field 'a' could not be resolved // is there any way to support it ? } 2) If find the reference of struct A.a, CDT cannot find this line: printf("%d",b_struct.a); Expected Results: CDT indexer should find the reference of MS-style anonymous struct's member.
The original report come from Eclipse Community Forums [Sun, 21 April 2013 13:47]: https://www.eclipse.org/forums/index.php/t/480262/ Bug I'm not sure the bug fired or not, only follow the post of Axel MuellerFriend: Axel MuellerFriend [Senior Member] You should file a bugzilla request https://bugs.eclipse.org This feature was added to the C11-Standard, see http://stackoverflow.com/questions/14105982/is-it-a-bad-idea-to-use-gccs-fms-extensions
Thanks for the report. CDT does not currently support this Microsoft extension, but we would probably be happy to accept a patch that adds support for it. The extension is documented at the bottom of this page: https://msdn.microsoft.com/en-us/library/a3bbz53t.aspx
Any news or progress on this front?! I'm using this feature extensively (C11 std!!) and the massive red underscores and missing completion are getting annoying. :( Thanks, C
Could someone link to some documentation or specification of this feature as standardized?
Unfortunately it looks costly: https://www.iso.org/standard/57853.html Netbeans has the same problem: https://netbeans.org/bugzilla/show_bug.cgi?id=256329 Wikipedia says little but mentions anon struct: https://en.wikipedia.org/wiki/C11_(C_standard_revision) GNU GCC is more detailed about the issue: https://gcc.gnu.org/onlinedocs/gcc/Unnamed-Fields.html Unfortunately what most people use still comes from the fms-extension. The following code compiles with -fms-extensions and _not_ with -std=c11: ------------------ struct A { int a; int b; }; struct B { struct A; int c; } b; int main() { return b.a; } ------------------- while this compiles with gcc -std=c11: ------------------- struct A { int b; int c; struct { int a; }; } b; int main() { return b.a; } -------------------- Would be perfect if the fms-extensions would work too... Although not strictly C11.
(In reply to Christian Huettig from comment #5) > Unfortunately it looks costly: > https://www.iso.org/standard/57853.html There are publically available drafts that are substantially identical: http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf > Wikipedia says little but mentions anon struct: > https://en.wikipedia.org/wiki/C11_(C_standard_revision) I believe that refers to something different - what you show in your second code example - which CDT already supports. > GNU GCC is more detailed about the issue: > https://gcc.gnu.org/onlinedocs/gcc/Unnamed-Fields.html This makes that pretty clear - your first example is a Microsoft extension, your second example is standard C11. > Would be perfect if the fms-extensions would work too... Although not > strictly C11. Given that at the moment we are struggling to keep up with new standard features, like C11 and C++14, adding support for non-standard extensions is not a priority right now. However, patches are welcome as mentioned in comment 2.
Any updates on this? My project is using gnu99 standard and I can define unions with anonymous members like struct b { union { struct a; struct a _base; ... }; }; but the indexer does not understand when I access b->member_of_a, but it compiles well.
Sorry, not gnu99 but gnu11
(In reply to Marv Lelgemann from comment #7) > Any updates on this? > > My project is using gnu99 standard and I can define unions with anonymous > members like > > struct b { > union { > struct a; > struct a _base; > ... > }; > }; > > but the indexer does not understand when I access b->member_of_a, but it > compiles well. I meant gnu11.