我正在用eclipse编写一个C应用程序,当发生奇怪的事件时。忽略指针赋值
我有一个函数,而我将指针传递给STRUCT,则函数内部,我分配给这个指针相同类型的其它指针,一个简单的分配这样
pointer = otherPointer;
然后,奇迹般地,我分配完全被程序忽略。我已经使用gdb进行了改进,并且我看到这个行的程序通过,并且该指令被忽略。
有一些人有这个超自然事件的原因的想法?
在程序中有类似的功能,具有类似的行为,分配正确完成。
这里是有问题的功能可按:
void uah_pcb_extract_queue_head (struct UAH_PCB * pPCB, struct UAH_PCB_Queue * pQueue)
{
if (pQueue->head->next != NULL)
{
pPCB = pQueue->head;
pQueue->head = pQueue->head->next;
}
else if (pQueue->head != NULL)
{
pPCB = pQueue->head;//this allocation
pQueue->head = NULL;//in this line the value has not changed
pQueue->tail = NULL;
}
else
{
pPCB = NULL;
}
}
如果添加的源代码,你的问题 –
向我们展示你的代码,而不是描述它,它会有所帮助。 – LihO
*“像这样简单的分配'pointer = otherPointer;'”* - 这只是一个赋值,在那个语句中没有分配。 – LihO