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.

C gibberish to English

163 pointsby naryadover 11 years ago

21 comments

geofftover 11 years ago
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 未加载
shurcooLover 11 years ago
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>
jankinsover 11 years ago
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 未加载
k4stover 11 years ago
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.
coherentponyover 11 years ago
Maybe it&#x27;s just me but having it written in English doesn&#x27;t actually help me understand complex declarations.
brianmwaters_hnover 11 years ago
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>
JoshTriplettover 11 years ago
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 未加载
Keyframeover 11 years ago
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 未加载
RossPenmanover 11 years ago
C gibberish to English gibberish.
mistercowover 11 years ago
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 未加载
BlobbleBlabover 11 years ago
For most programmers, the C notation is probably easier to read &#x2F; understand than the English gibberish derived from it with this tool
roryokaneover 11 years ago
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.
fishpiover 11 years ago
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.
jcox92over 11 years ago
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>
KiwiCoderover 11 years ago
Cool idea, although I expect everyone who understands the English version would also have understood the C version.
TorKlingbergover 11 years ago
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.
mjburgessover 11 years ago
&quot;I guess this&#x27;ll be used mainly for function pointers&quot;... first example.
justinhjover 11 years ago
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
Madrigalover 11 years ago
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
nraynaudover 11 years ago
too bad it doesn&#x27;t accept statements, I would be glad to get its take on a Duff&#x27;s device.
评论 #6316122 未加载
tbyehlover 11 years ago
I need a regex version of this.