clang-7: error: linker command failed with exit code 1 (use -v to see invocation) code example
Example: clang: error: linker command failed with exit code 1 (use -v to see invocation)
This happened to me simply because one function type did not match when
called recursively. I know there are other types of faults that might cause it.
But this is what happened to me.
Notice the Delete_Aux(t->left, item) recursive function calling.
TN *Delete_aux(TN *t, int item)
{
// complete this function
// write your code here
TN *temp;
if (t == NULL)
return NULL;
// if item is smaller go to the left node
if (t->data > item)
{
t->left = Delete_Aux(t->left, item); //Should be Delete_aux(t->right, item); Delete_Aux(t->left, item) is shown int type
return t;
}
else if (t->data < item)
{
t->right = Delete_Aux(t->right, item);
return t;
}
else
{
if (t->left == NULL && t->right == NULL)
{
free(t);
return NULL;
}
else if (t->left == NULL)
{
temp = t->right;
free(t);
return temp;
}
else if (t->right == NULL)
{
temp = t->left;
free(t);
return temp;
}
else
{
// get the smallest node in the right subtree temp = Leftmost(t->right)
t->data = temp->data;
t->right = Delete_Aux(t->right, temp->data);
return t;
}
}
}