//再一次遇到 if() 的条件判断中使用逗号操作符,此人必定蛋疼。
//举个栗子
,表示鄙视
#define get_buffer(pst,data) (((pst)->top == (pst)->end)? 0 : (( data = (pst)->pst[(pst)->end++]),1))
if( get_buffer( &glb->rcv_buff[num], data))
{
}
== (pst)->top != (pst)->end
if( ((data = (pst)->pst[(pst)->end++]),1) )
{
}
==
data = (pst)->pst[(pst)->end++];
if(1)
{
}
本文通过一个具体的代码示例,展示了如何在条件判断中使用逗号运算符,并对比了不同写法的效果。作者以此表达了对于在if语句中使用复杂逗号运算符的不推荐态度。
1372

被折叠的 条评论
为什么被折叠?



