Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

linked list thing warning: assignment from incompatible pointer type

I have a linked list sort of structure with the skeleton code shown below. However when I compile the code I get "warning: assignment from incompatible pointer type" for the operation temp = temp-> next. I'm just wondering why and if that 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;
}
like image 827
user1970979 Avatar asked Jul 27 '26 11:07

user1970979


1 Answers

You can't use the typedef before it's created. Change your struct to:

typedef struct data {
    size_t size;
    struct data* next;
} data_t;
like image 123
itsme86 Avatar answered Jul 29 '26 05:07

itsme86



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!