Linked list warning: assignment from incompatible pointer type

I have an associated list structure with the skeleton list shown below. However, when I compile the code, I get a "warning: assignment from incompatible pointer type" for temp = temp-> next operation. I'm just wondering why, and if it should be something to worry about. Thanks in advance!

typedef struct data {
    size_t size;
    struct data_t* next;
} data_t;

void* dmalloc(size_t numbytes) {
    while(temp!=NULL){
        if(temp->size>=numbytes) {
            //do something
        }
    temp = temp->next; //problem line
    }
return NULL;
}

      

+3


source to share


1 answer


You cannot use typedef before creating it. Change the structure:



typedef struct data {
    size_t size;
    struct data* next;
} data_t;

      

+3


source







All Articles