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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

C gibberish to English

163 点作者 naryad超过 11 年前

21 条评论

geofft超过 11 年前
This seems to be the same as the cdecl program available in most Linux distributions (apt-get install cdecl).<p>Websites for these little utilities are definitely useful, though. :)
评论 #6311800 未加载
评论 #6311523 未加载
shurcooL超过 11 年前
Neat site!<p><pre><code> &#x2F;&#x2F; declare foo as pointer to function (void) returning pointer to array 3 of int int (*(*foo)(void ))[3] </code></pre> That&#x27;s actually a great example to throw at Go&#x27;s syntax, which if you read from left-to-right, is perfectly one-to-one with the english:<p><pre><code> &#x2F;&#x2F; declare foo as pointer to function (void) returning pointer to array 3 of int var foo *func() *[3]int </code></pre> <a href="http://play.golang.org/p/1b48cjmZbx" rel="nofollow">http:&#x2F;&#x2F;play.golang.org&#x2F;p&#x2F;1b48cjmZbx</a>
jankins超过 11 年前
This is a great helper for getting acquainted with the C spiral rule: <a href="http://c-faq.com/decl/spiral.anderson.html" rel="nofollow">http:&#x2F;&#x2F;c-faq.com&#x2F;decl&#x2F;spiral.anderson.html</a>
评论 #6312444 未加载
评论 #6314324 未加载
评论 #6311819 未加载
评论 #6311601 未加载
k4st超过 11 年前
I also find this online utility useful when I don&#x27;t have c++filt (another program available to Linux distros) available:<p><a href="http://pear.warosu.org/c++filtjs/" rel="nofollow">http:&#x2F;&#x2F;pear.warosu.org&#x2F;c++filtjs&#x2F;</a><p>This can be used to demangle C++ names.
coherentpony超过 11 年前
Maybe it&#x27;s just me but having it written in English doesn&#x27;t actually help me understand complex declarations.
brianmwaters_hn超过 11 年前
I&#x27;m really surprised nobody&#x27;s mentioned that this is an exercise from K&amp;R (a.k.a. &quot;The C Programming Language&quot;), a must-read for any C programmer!<p><a href="https://en.wikipedia.org/wiki/The_C_Programming_Language" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;The_C_Programming_Language</a>
JoshTriplett超过 11 年前
This has some odd corner cases.<p>&quot;void f(void)&quot; -&gt; &quot;declare f as function (void) returning void&quot;<p>&quot;void fun(void)&quot; -&gt; &quot;declare fun as function (void) returning void&quot;<p>&quot;void funct(void)&quot; -&gt; &quot;declare funct as function (void) returning void&quot;<p>&quot;void func(void)&quot; -&gt; &quot;syntax error&quot;<p>&quot;func&quot; is not a special name in C.<p>Also:<p>&quot;void fn(void f(void))&quot; -&gt; &quot;syntax error&quot;<p>But this syntax works just fine:<p><pre><code> &#x2F;tmp$ cat test.c #include &lt;stdio.h&gt; void fn(void f(void)) { f(); f(); } void g(void) { puts(&quot;g&quot;); } int main() { fn(g); return 0; } &#x2F;tmp$ gcc test.c &#x2F;tmp$ .&#x2F;a.out g g</code></pre>
评论 #6311941 未加载
Keyframe超过 11 年前
the hell is this witchcraft? <a href="http://cdecl.ridiculousfish.com/?q=cast+foo+into+block%28int%2C+long+long%29+returning+double" rel="nofollow">http:&#x2F;&#x2F;cdecl.ridiculousfish.com&#x2F;?q=cast+foo+into+block%28int...</a>
评论 #6311490 未加载
评论 #6311482 未加载
评论 #6311479 未加载
RossPenman超过 11 年前
C gibberish to English gibberish.
mistercow超过 11 年前
I wonder how difficult it would be to write a C compiler (probably using LLVM would make sense) that translates an entire C program into English.
评论 #6316087 未加载
评论 #6317085 未加载
BlobbleBlab超过 11 年前
For most programmers, the C notation is probably easier to read &#x2F; understand than the English gibberish derived from it with this tool
roryokane超过 11 年前
Note that this is “C gibberish <i>↔</i> English”, not just “to English”. So it also converts (specially-formatted) English to C gibberish. The second and third examples at the top demonstrate this feature.
fishpi超过 11 年前
I did something like this using C++ template metaprogramming, which means you can make use of the compiler to figure out the types for you, and you just have to write class templates to produce the English description. It&#x27;s described at <a href="http://blog.asymptotic.co.uk/2011/02/c-type-declaration-decoder/" rel="nofollow">http:&#x2F;&#x2F;blog.asymptotic.co.uk&#x2F;2011&#x2F;02&#x2F;c-type-declaration-deco...</a> , although somewhere along the line the markup got corrupted so the code samples don&#x27;t quite render correctly.
jcox92超过 11 年前
I&#x27;m a fan of the &#x27;c-spiral&#x27; rule&#x2F; <a href="http://c-faq.com/decl/spiral.anderson.html" rel="nofollow">http:&#x2F;&#x2F;c-faq.com&#x2F;decl&#x2F;spiral.anderson.html</a>
KiwiCoder超过 11 年前
Cool idea, although I expect everyone who understands the English version would also have understood the C version.
TorKlingberg超过 11 年前
Cdecl is quite useful, but it does not work if you have declared your own types.<p>&quot;Foo a&quot; declares a of type Foo (whatever that is), but cdecl says Syntax Error.<p>It does not even work with C99 types. &quot;bool a&quot;, &quot;_Bool a&quot;, &quot;int32_t a&quot; all give Syntax Error.
mjburgess超过 11 年前
&quot;I guess this&#x27;ll be used mainly for function pointers&quot;... first example.
justinhj超过 11 年前
I&#x27;d like to see an equivalent for parsing common shell commands and their arguments. Just converting the short form to the long form would be a good start
Madrigal超过 11 年前
It can be a useful tool to get the main &quot;feeling&quot; in a complex line of pointers, but I wouldn&#x27;t use it to auto-generate explainer comments
nraynaud超过 11 年前
too bad it doesn&#x27;t accept statements, I would be glad to get its take on a Duff&#x27;s device.
评论 #6316122 未加载
tbyehl超过 11 年前
I need a regex version of this.