c编程gcc错误:从不兼容的指针类型分配[默认启用]

时间:2017-01-10 21:26:34

标签: c gcc

我有以下功能

TreeNode* findParentNode(TreeNode *tn, int parentData, int branchSelect)
{
    ListNode *temp1, *temp2;

    if (tn->data == parentData)
    {
        if ((branchSelect == 0 && tn->left == NULL) || (branchSelect == 1 && tn->right == NULL))
            return tn;
    }
    if (tn->left == NULL && tn->right == NULL)
        return NULL;



    temp1 = findParentNode(tn->left, parentData, branchSelect);
    if (temp1 != NULL)
        return temp1;

    temp2 = findParentNode(tn->right, parentData, branchSelect);
    if (temp2 != NULL)
        return temp2;
}

该函数应该返回父节点 它在vs上工作得很好但是当我在gcc上运行时我得到了上面的错误,我需要它在gcc下工作, 我读到了这个错误,但我仍然找不到解决方法。

some1可以帮我修复它,所以我也可以在gcc上运行它吗? 提前谢谢。

1 个答案:

答案 0 :(得分:2)

为什么不做

    ListNode *temp1, *temp2;

进入

    TreeNode *temp1, *temp2;

我看不出任何一个的定义...