TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

“:-!!” what is it in c code?

141 点作者 Arkid大约 13 年前

4 条评论

xd大约 13 年前
The actual line is <i>#define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); }))</i><p>The guy asking the question just misread the code, the colon is part of the struct definition and the key part is -!! which coerces an integer to 0 if the value is zero, or -1 if the value is anything other than 0.
评论 #3691464 未加载
评论 #3691734 未加载
apaprocki大约 13 年前
These machinations were always necessary to get compile-time asserts. Luckily C++11 and C11 are both providing static_assert so there will be <i>real</i> compiler support instead of having to trick it into dumping an error.<p>edit: Another common one is using __LINE__ or __COUNTER__ in an array symbol name and having the test value result in an array size of -1.
zokier大约 13 年前
Reminds me of the 'goes to' operator:<p><pre><code> for (int i = 42; i --&#62; 0;) { foo(); }</code></pre>
评论 #3691376 未加载
评论 #3691628 未加载
kyberias大约 13 年前
This has been posted before during the past 2 months.
评论 #3690502 未加载