I’m trying to cast a struct pointer to a void** for a function that takes a void**;
typedef struct {
uint64_t key; // the key in the key/value pair
void *value; // the value in the key/value pair
} HTKeyValue, *HTKeyValuePtr;
HTKeyValuePtr payload = (HTKeyValuePtr)malloc(sizeof(HTKeyValue));
int success = (HTKeyValuePtr) LLIteratorGetPayload(i, (void**) &payload);
gives me the warnings:
hashtable.c:161:19: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
hashtable.c:161:19: warning: initialization makes integer from pointer without a cast [enabled by default]
What’s going on? How do I fix this?
p.s. sorry if this is a dup of any other question. There were a lot of similar questions but I couldn’t find one that fit my situation and that I understood.
int success = (HTKeyValuePtr) LLIteratorGetPayload(i, (void**) &payload);You’re assigning a pointer into an int…
In addition, google tells me the first argument to
LLIteratorGetPayloadshould be aLLIter, which turns out to be atypedef void*. I’m guessingiis an integer. That’s the reason for the first error.