Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. lists.h
  2. #include "structs.h"
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <string.h>
  6.  
  7. typedef struct list{
  8. Instr head;
  9. struct list *tail;
  10. } *ILIST;
  11.  
  12. ILIST mkList(Instr, ILIST);```
  13.  
  14. lists.c
  15.  
  16. #include <stdlib.h>
  17. #include <stdio.h>
  18. #include <string.h>
  19. #include <ctype.h>
  20.  
  21. ILIST mkList(Instr n, ILIST l1) {
  22. ILIST l = malloc(sizeof(struct list));
  23. l->head = n;
  24. l->tail = l1;
  25. return l;
  26. }
  27.  
  28.  
  29. structs.h
  30.  
  31.  
  32. #include <stdio.h>
  33. #include <stdlib.h>
  34. #include <string.h>
  35.  
  36. typedef enum {START, QUIT, ATRIB, ADD, SUB, MUL, PRINT, READ, IF, GOTO, LABEL} OpKind;
  37. typedef enum {INT_CONST, STRING, EMPTY} ElemKind;
  38.  
  39. typedef struct{
  40. ElemKind kind;
  41. union
  42. {
  43. int val;
  44. char* name;
  45. }content;
  46. } Elem;
  47.  
  48.  
  49. structs.c
  50.  
  51.  
  52. #include "structs.h"
  53. #include <stdlib.h>
  54. #include <stdio.h>
  55. #include <string.h>
  56. #include <ctype.h>
  57.  
  58.  
  59. I get erros like this
  60.  
  61. In file included from lists.h:1:0,
  62. from main.c:3:
  63. structs.h:5:16: error: redeclaration of enumerator ‘START’
  64. typedef enum {START, QUIT, ATRIB, ADD, SUB, MUL, PRINT, READ, IF, GOTO, LABEL} OpKind;
  65. ^~~~~
  66.  
  67. In file included from main.c:1:0:
  68. structs.h:5:16: note: previous definition of ‘START’ was here
  69. typedef enum {START, QUIT, ATRIB, ADD, SUB, MUL, PRINT, READ, IF, GOTO, LABEL} OpKind;
  70. ^~~~~
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement