fork(1) download
  1. void undef (char *name)
  2. {
  3. struct nlist *curr, *last;
  4. unsigned hashval;
  5.  
  6. hashval = hash(name);
  7. last = curr = hashtab[hashval];
  8. while (curr != NULL && strcmp(name, curr->name)!= 0)
  9. {
  10. printf("while loop\n");
  11. last = curr;
  12. curr = curr->next;
  13. printf("last = %x, curr = %x\n", last, curr);
  14. }
  15.  
  16. printf("after loop\n");
  17. if (curr == hashtab[hashval])
  18. {
  19. hashtab[hashval] = NULL;
  20. return;
  21. }
  22. if (curr)
  23. {
  24. last->next = curr->next;
  25. free ((void *) curr->name);
  26. free ((void *) curr->defn);
  27. free (curr);
  28. }
  29. }
  30.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c: In function 'undef':
prog.c:6:19: warning: implicit declaration of function 'hash' [-Wimplicit-function-declaration]
         hashval = hash(name);
                   ^
prog.c:7:23: error: 'hashtab' undeclared (first use in this function)
         last = curr = hashtab[hashval];
                       ^
prog.c:7:23: note: each undeclared identifier is reported only once for each function it appears in
prog.c:8:24: error: 'NULL' undeclared (first use in this function)
         while (curr != NULL && strcmp(name, curr->name)!= 0)
                        ^
prog.c:8:32: warning: implicit declaration of function 'strcmp' [-Wimplicit-function-declaration]
         while (curr != NULL && strcmp(name, curr->name)!= 0)
                                ^
prog.c:8:49: error: dereferencing pointer to incomplete type 'struct nlist'
         while (curr != NULL && strcmp(name, curr->name)!= 0)
                                                 ^
prog.c:10:17: warning: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
                 printf("while loop\n");
                 ^
prog.c:10:17: warning: incompatible implicit declaration of built-in function 'printf'
prog.c:10:17: note: include '<stdio.h>' or provide a declaration of 'printf'
prog.c:13:24: warning: format '%x' expects argument of type 'unsigned int', but argument 2 has type 'struct nlist *' [-Wformat=]
                 printf("last = %x, curr = %x\n", last, curr);
                        ^
prog.c:13:24: warning: format '%x' expects argument of type 'unsigned int', but argument 3 has type 'struct nlist *' [-Wformat=]
prog.c:16:9: warning: incompatible implicit declaration of built-in function 'printf'
         printf("after loop\n");
         ^
prog.c:16:9: note: include '<stdio.h>' or provide a declaration of 'printf'
prog.c:25:17: warning: implicit declaration of function 'free' [-Wimplicit-function-declaration]
                 free ((void *) curr->name);
                 ^
prog.c:25:17: warning: incompatible implicit declaration of built-in function 'free'
prog.c:25:17: note: include '<stdlib.h>' or provide a declaration of 'free'
prog.c:4:18: warning: variable 'hashval' set but not used [-Wunused-but-set-variable]
         unsigned hashval;
                  ^
stdout
Standard output is empty