Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 2nd, 2012  |  syntax: None  |  size: 0.60 KB  |  hits: 17  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. C11 anonymous structs via typedefs?
  2. typedef struct {
  3.     struct {int a, b};
  4.     int c;
  5. } abc_struct;
  6.        
  7. typedef struct {
  8.     int a, b;
  9. } ab_struct;
  10.  
  11. typedef struct {
  12.     ab_struct;
  13.     int c;
  14. } abc_struct;
  15.        
  16. foo.c:6: warning: declaration does not declare anything
  17.        
  18. typedef struct {
  19.     int a, b;
  20. } ab_struct;
  21.  
  22. typedef struct {
  23.     ab_struct;
  24.     int c;
  25. } abc_struct;
  26.  
  27.  
  28. int main() {
  29.     abc_struct abc;
  30.     abc.a = 5;
  31.     return 0;
  32. }
  33.        
  34. typedef struct {
  35.     struct {
  36.             int a, b;
  37.     };
  38.         int c;
  39. } abc_struct;
  40.  
  41.  
  42. int main() {
  43.     abc_struct abc;
  44.     abc.a = 5;
  45.     return 0;
  46. }