Conflicting data types

I'm receiving an error: "conflicting types for 'size'" and a warning: "passing argument 1 of 'size' fro incompatible pointer type". This occurs in many spots in my code, but here is an example of one of the things I'm having issues with:

int bst_size(struct bst* bst) {
return size(bst->root);
}

int size(struct bst_node* curNode){ //This is where I'm receiving the error
//stuff here that is irrelevant to my question
}


and here are my structs defined:

struct bst_node {
int val;
struct bst_node* left;
struct bst_node* right;
};

struct bst {
struct bst_node* root;
};
Have you declared the size function previously? Make sure it has the correct return and parameter types in both places.
What you have here:

int bst_size(struct bst* bst) {

is a forward declaration. See:

http://en.cppreference.com/w/c/language/struct

So if bst is unknown at that time you cannot use one of its members.
Move the declaration of the structs before the first time you use it.
Topic archived. No new replies allowed.