c - undefined reference to avltree_init -
in code provided instructor there is:
typedef int (*avltree_cmp_fn_t)(const struct avltree_node *, const struct avltree_node *); int avltree_init(struct avltree *tree, avltree_cmp_fn_t cmp, unsigned long flags);
after define my_cmp function...
int my_cmp(const struct avltree_node *a, const struct avltree_node *b) { struct my_struct *p = avltree_container_of(a, my_struct, node); struct my_struct *q = avltree_container_of(b, my_struct, node); return p->key - q->key; }
and pass parameter avltree_init...
avltree_init(&tree, my_cmp, 0);
i get:
undefined reference `avltree_init(avltree*, int (*)(avltree_node const*, avltree_node const*), unsigned long)'
could explain, please, why happens , did make mistake? thanks!
it seems error message you're not linking file contains avltree_init function. need link files, including file containing function, final application. error comes linking phase, not compiling phase.
furthermore, see error message you're using c++ compiler c code. don't need that: more optimal use c compiler.
Comments
Post a Comment