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:
struct Node {
position* p;
struct Node* next;
struct Node* prev;
};
This is my declaration (on line 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
:
typedef struct Node Node;
Alternatively, you could use struct Node
in your declaration:
struct Node* hashtable[HashArraySize];
Change Node* hashtable[HashArraySize];
to struct Node* hashtable[HashArraySize];
or
typedef struct Node {
position* p;
struct Node* next;
struct Node* prev;
} Node;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With