fork download
  1. #include <stdio.h>
  2. struct month
  3. {
  4. char *name;
  5. int days;
  6. };
  7. int main()
  8. {
  9. #define m(a,b) { #a, a, b }
  10. enum indices {
  11. JAN = 1,FEB,MAR,APR,MAY,JUN,JUL,AUG,SEP,OCT,NOV,DEC
  12.  
  13. };
  14. struct month jan = m(JAN,31);
  15. struct month jan = m(FEB,28);
  16. struct month jan = m(MAR,31);
  17. struct month jan = {indices{apr = 4};};
  18. struct month jan = {indices{may = 5};};
  19. struct month jan = {indices{jun = 6};};
  20. struct month jan = {indices{jul = 7};};
  21. struct month jan = {indices{aug = 8};};
  22. struct month jan = {indices{sep = 9};};
  23. struct month jan = {indices{oct = 10};};
  24. struct month jan = {indices{nov = 11};};
  25. struct month jan = {indices{dec = 12};};
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c: In function ‘main’:
prog.c:14:26: warning: excess elements in struct initializer
 struct month jan = m(JAN,31);
                          ^
prog.c:9:26: note: in definition of macro ‘m’
  #define m(a,b) { #a, a, b }
                          ^
prog.c:14:26: note: (near initialization for ‘jan’)
 struct month jan = m(JAN,31);
                          ^
prog.c:9:26: note: in definition of macro ‘m’
  #define m(a,b) { #a, a, b }
                          ^
prog.c:15:14: error: redefinition of ‘jan’
 struct month jan = m(FEB,28);
              ^~~
prog.c:14:14: note: previous definition of ‘jan’ was here
 struct month jan = m(JAN,31);
              ^~~
prog.c:15:26: warning: excess elements in struct initializer
 struct month jan = m(FEB,28);
                          ^
prog.c:9:26: note: in definition of macro ‘m’
  #define m(a,b) { #a, a, b }
                          ^
prog.c:15:26: note: (near initialization for ‘jan’)
 struct month jan = m(FEB,28);
                          ^
prog.c:9:26: note: in definition of macro ‘m’
  #define m(a,b) { #a, a, b }
                          ^
prog.c:16:14: error: redefinition of ‘jan’
 struct month jan = m(MAR,31);
              ^~~
prog.c:15:14: note: previous definition of ‘jan’ was here
 struct month jan = m(FEB,28);
              ^~~
prog.c:16:26: warning: excess elements in struct initializer
 struct month jan = m(MAR,31);
                          ^
prog.c:9:26: note: in definition of macro ‘m’
  #define m(a,b) { #a, a, b }
                          ^
prog.c:16:26: note: (near initialization for ‘jan’)
 struct month jan = m(MAR,31);
                          ^
prog.c:9:26: note: in definition of macro ‘m’
  #define m(a,b) { #a, a, b }
                          ^
prog.c:17:14: error: redefinition of ‘jan’
 struct month jan = {indices{apr = 4};};
              ^~~
prog.c:16:14: note: previous definition of ‘jan’ was here
 struct month jan = m(MAR,31);
              ^~~
prog.c:17:21: error: ‘indices’ undeclared (first use in this function)
 struct month jan = {indices{apr = 4};};
                     ^~~~~~~
prog.c:17:21: note: each undeclared identifier is reported only once for each function it appears in
prog.c:17:28: error: expected ‘}’ before ‘{’ token
 struct month jan = {indices{apr = 4};};
                            ^
prog.c:18:14: error: redefinition of ‘jan’
 struct month jan = {indices{may = 5};};
              ^~~
prog.c:17:14: note: previous definition of ‘jan’ was here
 struct month jan = {indices{apr = 4};};
              ^~~
prog.c:18:28: error: expected ‘}’ before ‘{’ token
 struct month jan = {indices{may = 5};};
                            ^
prog.c:19:14: error: redefinition of ‘jan’
 struct month jan = {indices{jun = 6};};
              ^~~
prog.c:18:14: note: previous definition of ‘jan’ was here
 struct month jan = {indices{may = 5};};
              ^~~
prog.c:19:28: error: expected ‘}’ before ‘{’ token
 struct month jan = {indices{jun = 6};};
                            ^
prog.c:20:14: error: redefinition of ‘jan’
 struct month jan = {indices{jul = 7};};
              ^~~
prog.c:19:14: note: previous definition of ‘jan’ was here
 struct month jan = {indices{jun = 6};};
              ^~~
prog.c:20:28: error: expected ‘}’ before ‘{’ token
 struct month jan = {indices{jul = 7};};
                            ^
prog.c:21:14: error: redefinition of ‘jan’
 struct month jan = {indices{aug = 8};};
              ^~~
prog.c:20:14: note: previous definition of ‘jan’ was here
 struct month jan = {indices{jul = 7};};
              ^~~
prog.c:21:28: error: expected ‘}’ before ‘{’ token
 struct month jan = {indices{aug = 8};};
                            ^
prog.c:22:14: error: redefinition of ‘jan’
 struct month jan = {indices{sep = 9};};
              ^~~
prog.c:21:14: note: previous definition of ‘jan’ was here
 struct month jan = {indices{aug = 8};};
              ^~~
prog.c:22:28: error: expected ‘}’ before ‘{’ token
 struct month jan = {indices{sep = 9};};
                            ^
prog.c:23:14: error: redefinition of ‘jan’
 struct month jan = {indices{oct = 10};};
              ^~~
prog.c:22:14: note: previous definition of ‘jan’ was here
 struct month jan = {indices{sep = 9};};
              ^~~
prog.c:23:28: error: expected ‘}’ before ‘{’ token
 struct month jan = {indices{oct = 10};};
                            ^
prog.c:24:14: error: redefinition of ‘jan’
 struct month jan = {indices{nov = 11};};
              ^~~
prog.c:23:14: note: previous definition of ‘jan’ was here
 struct month jan = {indices{oct = 10};};
              ^~~
prog.c:24:28: error: expected ‘}’ before ‘{’ token
 struct month jan = {indices{nov = 11};};
                            ^
prog.c:25:14: error: redefinition of ‘jan’
 struct month jan = {indices{dec = 12};};
              ^~~
prog.c:24:14: note: previous definition of ‘jan’ was here
 struct month jan = {indices{nov = 11};};
              ^~~
prog.c:25:28: error: expected ‘}’ before ‘{’ token
 struct month jan = {indices{dec = 12};};
                            ^
prog.c:25:28: error: expected declaration or statement at end of input
prog.c:25:14: warning: unused variable ‘jan’ [-Wunused-variable]
 struct month jan = {indices{dec = 12};};
              ^~~
stdout
Standard output is empty