fork download
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. #define node(key_t, value_t) \
  5.   typedef struct node { \
  6.   key_t key; \
  7.   value_t value; \
  8.   } node
  9.  
  10. int main(int argc, const char * argv[]) {
  11. node(char*, int);
  12. node* n = malloc(sizeof(node*));
  13. n->key = "first";
  14. n->value = 1;
  15.  
  16. printf("the node n has a key of %s and a value of %d.\n", n->key, n->value);
  17.  
  18. // error starts from here
  19. node(char, char*);
  20. node* n2 = malloc(sizeof(node*));
  21. n2->key = 'a';
  22. n2->value = "first";
  23.  
  24. printf("the node n2 has a key of %c and value of %s.\n", n2->key, n2->value);
  25.  
  26. return 0;
  27. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c: In function ‘main’:
prog.c:19:5: error: redefinition of ‘struct node’
prog.c:11:5: note: originally defined here
prog.c:19:5: error: conflicting types for ‘node’
prog.c:11:5: note: previous declaration of ‘node’ was here
stdout
Standard output is empty