【发布时间】:2010-12-23 10:46:57
【问题描述】:
你能为我解释一下这个错误吗?
在我的 A.h 文件中:
struct TreeNode;
struct TreeHead;
typedef struct TreeNode * Node;
typedef struct TreeHead * Head;
在我的 A.c 文件中:
struct TreeNode {
char* theData;
Node Left;
Node Right;
} ;
struct TreeHead{
int counter;
char type;
Node Root;
};
Head Initialisation() {
Head treeHead;
treeHead = malloc(sizeof (struct TreeHead));
treeHead->Root = malloc(sizeof (struct TreeNode));
return treeHead;
}
在我的 Main.c 文件中:
Head head;
Node tree;
int choose =5;
head = Initialisation();
(head->Root) = tree; //When compiling, this line has an error: error: dereferencing pointer to incomplete type
haed->Root 会返回一个 Node 指针,tree 也是一个 Node 指针。那么为什么错误是取消引用指向“不完整”类型的指针呢?
【问题讨论】:
-
你使用的是什么编译器。
gcc可以使用您的代码语法。 -
我使用 gcc 但我打开了所有警告和错误消息。
标签: c compiler-errors