gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-30 17:22:31 27 4
gpt4 key购买 nike

我的项目头目录中有两个头文件,分别是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 和上一个问题的意思:如果您在声明函数或其原型(prototype)之前调用像 node* first() 这样的函数,编译器会假设它会是一个返回int的函数。确保您已启用所有编译器警告并处理每一个警告。

关于c - 如何在 Visual Studio 2013 中修复 "differs in level of indirection",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28003786/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com