Pergunta

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;
}
Foi útil?

Solução

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;
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top