I have a function which when compiled using gcc works fine, but when I compile it with g++, it gives me this error:
bon_io.cpp:In function ‘lruc_item* lruc_pop_or_create_item(lruc*)’:
bon_io.cpp:4751: error: invalid conversion from ‘void*’ to ‘lruc_item*’
Code:
typedef struct {
void *value;
void *key;
uint32_t value_length;
uint32_t key_length;
uint64_t access_count;
void *next;
} lruc_item;
lruc_item* lruc_pop_or_create_item(lruc *cache1)
{
lruc_item *item = NULL;
if(cache1->free_items) {
item = cache1->free_items;
cache1->free_items = item->next; [LINE 4751]
} else {
item = (lruc_item *) calloc(sizeof(lruc_item), 1);
}
return item;
}
I am trying to use this function with a c++ code, that’s why need to compile it with g++, it works fine if I compile it using gcc but not with g++.
Can anyone please suggest me a way out to make this work with g++ ?
Thanks
How about:
Because in C++ you can’t automatically convert from
void *to another pointer type.