Reputation: 85
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;
}
Upvotes: 3
Views: 1268
Reputation: 19486
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;
Upvotes: 3