且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在C宏,应在preFER做{...}而(0,0)重来一次{...}而(0)?

更新时间:2023-12-04 11:39:28

好吧,我去了一个答案:

Well, I'll go for an answer:

是否有正当的理由为什么要preFER宏的第二种形式...?

Is there a legitimate reason why one should prefer the second form of the macro... ?

没有。没有正当的理由。双方总是为false,任何像样的编译器可能会变成第二个到在装配第一反正。如果有任何理由为它在某些情况下无效,C一直围绕远远不够长,因此要由比我大宗师发现的。

No. There is no legitimate reason. Both always evaluate to false, and any decent compiler will probably turn the second one into the first in the assembly anyway. If there was any reason for it to be invalid in some cases, C's been around far long enough for that reason to be discovered by greater gurus than I.

如果你在你喜欢你的code制作猫头鹰-Y的眼睛,用而(0,0)。否则,用什么C编程世界的其余部分使用,并告诉客户的静态分析工具来推它。

If you like your code making owl-y eyes at you, use while(0,0). Otherwise, use what the rest of the C programming world uses and tell your customer's static analysis tool to shove it.