TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Detecting integer constant expressions in macros

79 pointsby BtdTomabout 7 years ago

5 comments

chrisseldoabout 7 years ago
&quot;I&#x27;m in awe of your truly marvelously disgusting hack. That is truly a work of art.&quot;<p>Ha. How should one take such a comment?
评论 #16702380 未加载
评论 #16702971 未加载
评论 #16703357 未加载
评论 #16702508 未加载
评论 #16702719 未加载
评论 #16702381 未加载
marshrayabout 7 years ago
Go on, tell me again about how C++ compile-time metaprogramming is so horrible ...
评论 #16705509 未加载
评论 #16705131 未加载
djhaskin987about 7 years ago
The reply of the guy Linus is addressing is worth a read: <a href="https:&#x2F;&#x2F;lkml.org&#x2F;lkml&#x2F;2018&#x2F;3&#x2F;20&#x2F;871" rel="nofollow">https:&#x2F;&#x2F;lkml.org&#x2F;lkml&#x2F;2018&#x2F;3&#x2F;20&#x2F;871</a>
ksherlockabout 7 years ago
I didn&#x27;t believe it would work but it does. It boils down to<p><pre><code> sizeof(int) == sizeof(void) </code></pre> vs<p><pre><code> sizeof(int) == sizeof(int) </code></pre> As a non-standard extension, in gcc (and thus clang and icc for compatibility, it seems) void has a size of 1. In a conforming compiler, it&#x27;s an error.
评论 #16706090 未加载
kuonabout 7 years ago
I&#x27;ve been writing C for 20 years and I have no idea what I am reading.
评论 #16704199 未加载