根据我的理解,我将变量的地址传递a给函数int ffx1.
在那之后,这条线究竟p = (int[2]){*p};意味着什么?
int ffx1(int * p)
{
p = (int[2]){*p};
return(p[1]);
}
int main()
{
int a = 1;
a = ffx1(&a);
printf("%d", a);
return 0;
}
Run Code Online (Sandbox Code Playgroud) 我正在浏览一些嵌入式编程链接 http://www.micromouseonline.com/2016/02/02/systick-configuration-made-easy-on-the-stm32/
【注意上面链接的代码作者已经更新了代码,delay_ms()文章中的实现不再使用下图所示的解决方案。】
并最终得到以下代码。这是针对 ARM 架构的,但基本上这是一个函数,它会导致作为参数传递的某些毫秒的延迟。所以我可以理解 if 条件,但为什么这里需要 else 条件?有人可以向我解释一下吗?
void delay_ms (uint32_t t)
{
uint32_t start, end;
start = millis();//This millis function will return the system clock in
//milliseconds
end = start + t;
if (start < end) {
while ((millis() >= start) && (millis() < end))
{ // do nothing }
}
else{
while ((millis() >= start) || (millis() < end))
{
// do nothing
};
}
}
Run Code Online (Sandbox Code Playgroud)