문제

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;
}
도움이 되었습니까?

해결책

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;
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top