1

;void**を取る関数の構造体ポインタをにキャストしようとしています。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);

私に警告を与えます:

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]

どうしたの?これを修正するにはどうすればよいですか?

これが他の質問の重複である場合は申し訳ありません。似たような質問がたくさんありましたが、自分の状況に合った質問が見つからず、理解できました。

4

1 に答える 1

4

int success = (HTKeyValuePtr) LLIteratorGetPayload(i, (void**) &payload);

ポインタをintに割り当てています...

さらに、グーグルは私に最初の引数はLLIteratorGetPayloadであるはずだと言っていますLLIter、それはであることがわかりますtypedef void*i整数だと思います。それが最初のエラーの理由です。

于 2012-07-05T19:19:13.367 に答える