错误:函数类型冲突,函数在头文件中声明

Lol*_*lyW 5 c compiler-errors function

因此,我尝试使用makefile和头文件等编译一个多文件程序。即使我已经一百万次仔细检查了该类型,但我仍然得到了这个程序,并不断遇到相同的错误。救命!

错误:

search.c:11: error: conflicting types for 'search' search.h:1: note: previous declaration of 'search' was here

这是我的.h文件

int search(struct intnode** root, int lookingfor, int* counter);
Run Code Online (Sandbox Code Playgroud)

这是我的.c文件

#include "search.h"
#include "intnode.h"
#include <stdlib.h>
#include <stdio.h>

/*
Usage:
  search(root, value);
*/

int search(struct intnode** root, int lookingfor, int* counter) {

  /*COMPARE TO ROOT KEY*/
  /*IF EQUAL*/
  if(int_compare(lookingfor, (*root)->key) == 0) {
    printf("%d exists in tree", lookingfor);
    counter++;
    if ((*root)->R != NULL && (*root)->key == (*root)->R) {
      search((*root)->R, lookingfor, *counter);
    }
  }

  /*IF GREATER THAN AND THERE IS A CHILD*/
  else if(int_compare(lookingfor, (*root)->key) == 1 && (*root)->R != NULL) {  
    search((*root)->R, lookingfor, *counter);
    counter++;
  }

  /*IF LESS THAN AND THERE IS A CHILD*/
  else if(int_compare(lookingfor, (*root)->key) == 2 && (*root)->L != NULL) {
    search((*root)->L, lookingfor, *counter);
    counter++;
  }
  return NULL;
}
Run Code Online (Sandbox Code Playgroud)

mks*_*eve 2

确保在声明intnode之前定义。search()