[英]invalid operands to binary expression ('struct node ' and 'struct node ')
I have made a header file in which I have declared a struct node
and made an object as List
of that struct. 我已经创建了一个头文件,我在其中声明了一个
struct node
,并将一个对象作为该struct的List
。 Here is my header file link.h : 这是我的头文件link.h :
struct node
{
void *data; //Generic data
struct node *next;
}List;
Driver.c : Driver.c :
#include "link.h"
int main()
{
List list1;
return 0;
}
When I am trying to write a statement like 当我试图写一个像这样的声明
List list1; //in the driver file
It throws up an error saying: 它引发了一个错误说:
invalid operands to binary expression ('struct node' and 'struct node')
二进制表达式的无效操作数('struct node'和'struct node')
use of undeclared identifier 'list1';
使用未声明的标识符'list1'; did you mean 'List'?
你的意思是'列表'?
What could be causing this? 可能是什么导致了这个?
Most probably your intention is to have List
being an alias for struct node
, so you need to use typedef
, otherwise List
is not a type but an instance variable of the struct. 很可能你的意图是让
List
成为struct node
的别名,所以你需要使用typedef
,否则List
不是类型,而是struct的实例变量。
typedef struct node
{
void *data; //Generic data
struct node *next;
}List;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.