A Question about dereferencing pointer to incomplete type In C programming
Posted
by
user552279
on Stack Overflow
See other posts from Stack Overflow
or by user552279
Published on 2010-12-23T10:46:57Z
Indexed on
2010/12/23
10:54 UTC
Read the original article
Hit count: 190
Filed under:
c
Hi, can you explain this error for me?
Blockquote
/////////////////////////////// In my A.h file: struct TreeNode; struct TreeHead; typedef struct TreeNode * Node; typedef struct TreeHead * Head; /////////////////////////////// In my A.c file: 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; } /////////////////////////////// In my Main.c file: 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
Blockquote
haed->Root will return a Node pointer, tree is also a Node pointer. So why error is dereferencing pointer to "incomplete" type?
© Stack Overflow or respective owner