I know there are at least 10 questions already about this, but they all point to something I am not doing.

In a header file I have...

typedef struct Node {
   struct Node *next;
   struct pgmap page;
} Node;

typedef struct linkedlist {
struct Node *head_ptr;
struct Node *tail_ptr;
} LList;

In my c file I have

struct LList mainList;

int main()
{
    struct LList *root;
    root = &mainList;
    root->head_ptr = NULL;
    root->tail_ptr = NULL;
    ...
}

On the root-> lines I get the dereferencing ptr... error. All the threads already on here point to a problem where people accidentally create anonymous structs, such as

typedef struct{
    int a;
}; monkey

instead of

typedef struct monkey{
    int a;
}; monkey

So what am I missing????

有帮助吗?

解决方案

There is no type called "struct LList". The code "typedef struct linkedlist { ... } LList;" creates two type names: one is struct linkedlist, and the other is just LList (without "struct"). You thus need to change "struct LList" to "LList."

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top