[英]Typedef redefinition with different types ('struct TGAME' vs 'struct TGAME')
[英]typedef redefinition with different types ('struct word' vs 'struct word') };
我在完成這項任務時遇到了困難,每當我使用其他結構創建鏈表時,我都會收到錯誤消息。
鏈表
#include "sentence.c"
typedef struct{
sentence *first;
int numSentences;
}LinkedList;
句子c
#include "word.c"
typedef struct{
word *sentence;
int lineNumber;
int numWords;
}sentence;
字.c
typedef struct{
char *word;
int numCharacters;
int wordPos;
}word;
我只有在實現鏈表部分時才會遇到問題,當我使用句子和單詞結構進行編譯時,它們工作正常。 我沒有在任何地方初始化鏈表,它仍然為句子和單詞給出這個錯誤:
我不太確定這個錯誤意味着什么,因為我不相信我會在其他任何地方重新聲明它。
你不應該 #include ".c" 文件。 #include 僅適用於“.h”文件。
但這很可能不是錯誤的主要原因,盡管不這樣做會簡化故障排除。
您很可能在其他 2 個文件中包含 word.c - 直接或間接
您還應該習慣於為頭文件添加包含保護,以修復同一頭文件的多個包含。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.