gpt4 book ai didi

c++ - 为什么功能没有完全执行?

转载 作者:行者123 更新时间:2023-11-28 04:01:11 25 4
gpt4 key购买 nike

当我尝试调试以下函数段时,执行在 pCellTower->m_pCellTowerInfo = pCellInfo 行停止(跳出函数):

RILCELLTOWERINFO* pCellInfo = (RILCELLTOWERINFO*)lpData;

CCellTower *pCellTower = (CCellTower*)cbData;
if(pCellTower != NULL)
{
pCellTower->m_pCellTowerInfo = pCellInfo;
}

(未设置指针 pCellInfo)

然后我试着评论这行:

RILCELLTOWERINFO* pCellInfo = (RILCELLTOWERINFO*)lpData;

CCellTower *pCellTower = (CCellTower*)cbData;
if(pCellTower != NULL)
{
//pCellTower->m_pCellTowerInfo = pCellInfo;
}

这样函数就可以正常执行了。

有谁知道哪里出了问题?

最佳答案

最可能的解释是 pCellTower 也未设置。它可能包含随机位,并最终指向分配给您的应用程序的内存之外。操作系统不允许您的程序在分配给它的空间之外写入,因此它会向程序发送写入被拒绝的某种消息(Windows:异常,Unix/Linux:信号)。

关于c++ - 为什么功能没有完全执行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/442550/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com