C语言报错:conflicting types for 'xxx'

error: conflicting types for 'xxx'
error: previous implicit declaration of 'xxx' was here

原因1:没有先做函数声明,而函数又位于main()函数之后

// err1.c
#include 
#include 

typedef struct Node
{
    int data;
    struct Node *pNext;
} NODE, *PNODE;

int main()
{
    PNODE pHead = NULL;
    if(is_empty(pHead))
        printf("链表为空!\n");
    else
        printf("链表不空!\n");

    return 0;
}

bool is_empty(PNODE pHead)
{
    if(NULL == pHead->pNext)
        return true;
    else
        return false;
}
C语言报错:conflicting types for 'xxx'_第1张图片

原因2:函数声明(可能在.c / .h中)和定义(.c中)的参数稍有不同

例如:

头文件中声明:void Hander(const char * buf);
在定义时写成:void Hander(char * buf);

原因3:头文件被循环引用,在引用时包含顺序导致(需考虑清楚包含顺序)

你可能感兴趣的:(C语言报错:conflicting types for 'xxx')