访问冲突强制转换为void *并返回 [英] access violation casting to void* and back
本文介绍了访问冲突强制转换为void *并返回的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
尝试以下操作时,我将获得访问冲突读取位置.我在做什么错了?
I get an access violation reading location when I try the following. What am I doing wrong?
uint64_t hInt = 2901924954136;
void* hPoint = reinterpret_cast<void*>(hInt);
uint64_t hIntBack = *static_cast<uint64_t*>(hPoint); //get access violation
here
推荐答案
我猜您打算将hInt
的地址存储在hPoint
中,而不是hInt
的值中.
I am guessing you meant to store the address of hInt
in hPoint
, not the value of hInt
.
uint64_t hInt = 2901924954136;
void* hPoint = reinterpret_cast<void*>(&hInt);
// ^ addressof operator
这篇关于访问冲突强制转换为void *并返回的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文