履歴情報を保持するリンク リストを実装しようとしています。
私のノード構造の定義は次のとおりです。
struct HistoryNode {
int Value;
struct HistoryNode *Last, *Next;
};
リスト内のヘッド/テール/現在のノードへのポインターを含む別の構造も作成しました。
struct _History {
struct HistoryNode *Head, *Tail, *Current;
} History = {
NULL, NULL, NULL,
};
最後に、ノードをリストに追加する関数を作成しました。
void AddHistory(void) {
struct HistoryNode *NewNode;
//Allocate new node memory
NewNode = malloc(sizeof(NewNode));
if(NewNode == NULL) {
Die("malloc(%d) failed", sizeof(NewNode));
}
//Re-arrange pointers in new node and head/tail/current
if(History.Current == NULL) {
NewNode->Next = NULL;
NewNode->Last = NULL;
History.Current = NewNode;
History.Head = NewNode;
History.Tail = NewNode;
} else {
NewNode->Next = NULL;
NewNode->Last = History.Current;
History.Current = NewNode;
History.Tail = NewNode;
}
}
GCC は、いくつかのエラーとともにこれを吐き出します。
Scribe.c: In function 'AddHistory':
Scribe.c:509:15: error: request for member 'Current' in something not a structure or union
Scribe.c:513:16: error: request for member 'Current' in something not a structure or union
Scribe.c:514:16: error: request for member 'Head' in something not a structure or union
Scribe.c:515:16: error: request for member 'Tail' in something not a structure or union
Scribe.c:518:32: error: request for member 'Current' in something not a structure or union
Scribe.c:520:16: error: request for member 'Current' in something not a structure or union
Scribe.c:521:16: error: request for member 'Tail' in something not a structure or union
なぜこれが起こっているのかわかりません、何か助けはありますか?
ありがとう - アレックス