Re: dereferencing pointer to incomplete type



Hello,

while I was trying to write some recursive functions for my current application
I got stuck with the following problem.

I have a structure like this :

typedef struct AdressBookItem {
        ...
        GtkCTreeNode *tree_item;
        struct _AdressBookItem *parent;
        ...
} AdressBookItem;

Either the first line should be typedef struct _AdressBookItem
or the second line of the struct should be struct AdressBookItem *parent;


But when I try something like this in my code :

void blabla (AdressBookItem *adr) {
        ...
        GtkCTreeNode *parent;

        ...
        parent = adr->parent->tree_item;         << THIS LINE
        ...
}

I get a compiler error "dereferencing pointer to incomplete type" for THIS LINE.
I read some FAQs and Tutorials but didn't find an answer.

So could anybody please give me an advice?

It is because parent is dereferencing to struct _AdressBookItem and the compiler
doesn't know what a struct _AdressBookItem is, only what struct AdressBookItem is.

iain





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]