我正在为嵌入式软件课程做任务,但我遇到了奇怪的问题。
使用以下代码:
void decidePotato(float held)
{
printf("Deciding Potato, held for %f seconds \n", held);
if (held >= 1.99)
{
printf("Held for more than 1.99s \n", held);
returnPotato();
}
printf("I evaluated the if statement above \n");
}
我得到以下输出:
Deciding Potato, held for 0.010000 seconds
我甚至没有看到“我评估了以上的if语句”消息,所以程序在评估该if语句时出现了某种卡顿。并且它一直卡着,直到我重新编程板子。这怎么可能呢?
returnPotato
里面是什么? - ouahreturnPotato
包含什么? - jsalonenfflush(stdout)
。有时候消息会在通道中被阻塞(尽管通常假定启用了行缓冲),导致不清晰的行为。一旦理解了问题,别忘了将它们删除 - 它们可能非常低效。 - sh1