0

error: dereferencing pointer to incomplete type
The problem line is "gl->point[0] = (struct list *)&foo;"
I read somewhere that I could be storing a declaration. If that is the case I need that explained to me.

struct ref {  
    char **name;
    struct list **point;
};

int main ( ) {   
    typedef struct {
        char **name;
        struct list **point;
    } temp;  

    struct ref *gl;  

    gl->name = malloc ( 1024 * sizeof(char *) );  
    gl->name[0] = "A";  

    temp foo;  
    foo.name = malloc ( 1024 * sizeof(char *) );  
    foo.name[0] = "B";  

    gl->point[0] = (struct list *)&foo;   

    printf ( "!%s!\n" , gl->point[0]->name[0] );  
}
2
  • Note that the typedef temp and the struct ref types are not the 'same type'; you should not repeat code like that. Commented Oct 3, 2010 at 15:16
  • Oh, I mistook all structs to be the same type. that helps a lot. Commented Oct 3, 2010 at 15:25

2 Answers 2

1

What's struct list? There is no type named struct list (at least in what you've shown).

Maybe you meant struct ref?

Sign up to request clarification or add additional context in comments.

Comments

0

Nowhere in the code sample are you defining struct list which is what the error is.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.