[英]Unknown type name C
I know that things have to be defined before they are used, but I am getting an "unknown type name error." 我知道在使用它们之前必须先定义它们,但是我得到了一个“未知类型名称错误”。
This is my Node
definition: 这是我的
Node
定义:
struct Node {
position* p;
struct Node* next;
struct Node* prev;
};
This is my declaration (on line 96): 这是我的声明(第96行):
Node* hashtable[HashArraySize];
I get this error message: 我收到此错误消息:
P1.c:96:1: error: unknown type name ‘Node’
Node* hashtable[HashArraySize];
Unlike C++ which treats struct
tags as new type names, C requires an explicit typedef if you wish to use Node
without struct
: 与将
struct
标记视为新类型名称的C ++不同,如果您希望使用不带struct
Node
,则C需要显式的typedef:
typedef struct Node Node;
Alternatively, you could use struct Node
in your declaration: 或者,您可以在声明中使用
struct Node
:
struct Node* hashtable[HashArraySize];
Change Node* hashtable[HashArraySize];
Change
Node* hashtable[HashArraySize];
to struct Node* hashtable[HashArraySize];
struct Node* hashtable[HashArraySize];
or 要么
typedef struct Node {
position* p;
struct Node* next;
struct Node* prev;
} Node;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.