c - undefined reference to 'freeHeap' -
i have encountered problem when calling freeheap function inside of sortcomp.c
i calling such
heapref myheap = buildheap(numdata, heapsort, numdata); freeheap(myheap);
when compiling recieve error "undefined reference 'freeheap'"
i including heap.h , inside of heap.h have declared freeheap
void freeheap(heapref *);
i compiling such
gcc -o sortcomp sortcomp.c insertionsort.c heap.c insertionsort.h heap.h
it defined in heap.c as
void freeheap(heapref *ph){ heapref h = *ph; free(h->data); free(h); }
fixed:
i changed calling of freeheap(myheap);
to
freeheap(&myheap);
and stopped complaining
use in declaration of function freeheap()
in heap.h
:
extern void freeheap(heapref*);
edit jesus christ, argument freeheap()
doesn't match prototype's, declaration doesn't match definition.so argument needs of type heapref*
instead of heapref
.in program myheap
of type heapref
while supposed pass heapref*
.use this:
freeheap(&myheap);
Comments
Post a Comment