c语言 - 如何在Visual Studio 2013中修复"differs in level of indirection"



我在项目的头目录中有两个头文件,即list.hlist-interface.h,分别包含数据类型的声明和该数据类型的函数声明。

//list.h   
typedef struct Container{
       int item;
       struct Container *next;
}node;
//list-interface.h
 node *first(node *);
 ......
  //some other declarations.
Then in the resource directory i have list-methods.c.   
//list-=methods.c  
 int is_last(node *lis_ptr, node *nod_ptr)
 {
    int islast = 0;
    if (nod_ptr == last(lis_ptr))
    islast = 1;
    return islast;
 }
 //returns 1 if the second argumented pointer points to the first element of the list,pointed by first argumented pointer.other wise 0.
 int is_first(node *lis_ptr, node *nod_ptr){
      int isfirst = 0;
      if (nod_ptr == first(lis_ptr))
          isfirst = 1;
      return isfirst;
  }
  //accessor methods------------------------------
  //returns the pionter to first element in the list.
  node* first(node *lis_ptr)
  {
      return lis_ptr;
  }
  //returns the pointer to last element in the list.
  node *last(node *lis_ptr)
  {
      while (lis_ptr->next != NULL)
      lis_ptr = lis_ptr->next;
      return lis_ptr;
  }

//This returns the pointer to the previous element to the node pointed by nod_ptr (second argument) in the list.
 node *before(node *first_ptr, node *nod_ptr)
 {
     if (first_ptr == nod_ptr){
        return NULL;
     }
     else{
        while (first_ptr->next != nod_ptr)
        first_ptr = first_ptr->next;
     }
    return first_ptr;
 }

但是当我在Visual Studio 2013中编译list-methods.c的代码时,我收到以下错误

node*(node *) differs in level of indirection from int().

请为我提供一些解决方案。

为了说明@BLUEPIXY和上一个问题在说什么:如果您在声明函数或其原型之前调用像node* first()这样的函数,编译器会假设它将是一个返回int的函数。确保已启用所有编译器警告并处理每个警告。

相关内容

  • 没有找到相关文章