error: conflicting types for 'xxx'
error: previous implicit declaration of 'xxx' was here
原因1:沒有先做函數(shù)聲明器腋,而函數(shù)又位于main()函數(shù)之后
// err1.c
#include <stdio.h>
#include <stdbool.h>
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;
}
原因2:函數(shù)聲明(可能在.c / .h中)和定義(.c中)的參數(shù)稍有不同
例如:
頭文件中聲明:void Hander(const char * buf);
在定義時寫成:void Hander(char * buf);