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.

Improving _Generic in C2y

51 pointsby luu10 months ago

4 comments

fanf210 months ago
The article describes two problems with _Generic.<p>There is a third: the discarded branches must typecheck. (Unlike C++ templates, where substitution failure is not an error.) Simon Tatham described the issue in more detail:<p><a href="https:&#x2F;&#x2F;www.chiark.greenend.org.uk&#x2F;~sgtatham&#x2F;quasiblog&#x2F;c11-generic&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.chiark.greenend.org.uk&#x2F;~sgtatham&#x2F;quasiblog&#x2F;c11-g...</a>
评论 #41156974 未加载
评论 #41156375 未加载
评论 #41156170 未加载
评论 #41156091 未加载
评论 #41157939 未加载
评论 #41158961 未加载
colonwqbang10 months ago
Nice, does this mean we can have const-generic accesors now? I.e. &amp;s-&gt;somefield and get a const pointer if s was a const pointer, but a mutable one otherwise? I guess we still need to define two functions though, but that can probably be handled by macros. This is something that really hinders use of const in current C.
Conscat10 months ago
Clang, as a non-standard feature, allows you to put a type-id into `_Generic` rather than an expression.
评论 #41157442 未加载
brcmthrowaway10 months ago
Wow, I can&#x27;t believe they wasted a decade on 2 releases<p>Move fast!
评论 #41156881 未加载
评论 #41159682 未加载