C gibberish to English
cdecl.org
cdecl.org
Websites for these little utilities are definitely useful, though. :)
// declare foo as pointer to function (void) returning pointer to array 3 of int
int (*(*foo)(void ))[3]
That's actually a great example to throw at Go's syntax, which if you read from left-to-right, is perfectly one-to-one with the english: // declare foo as pointer to function (void) returning pointer to array 3 of int
var foo *func() *[3]int
http://play.golang.org/p/1b48cjmZbxWhat works for me is "type declaration mimics usage". So I find the variable name, parse the declaration as usage and then reconstruct the type. It goes like this:
char *((*foo)[3])(int);
Ok, so if you dereference foo, then index[3], then call with int, then dereference, you get char?Cool, looks like foo is a pointer to an array of size 3 of functions that take int and return pointer to char.
http://pear.warosu.org/c++filtjs/
This can be used to demangle C++ names.
"void f(void)" -> "declare f as function (void) returning void"
"void fun(void)" -> "declare fun as function (void) returning void"
"void funct(void)" -> "declare funct as function (void) returning void"
"void func(void)" -> "syntax error"
"func" is not a special name in C.
Also:
"void fn(void f(void))" -> "syntax error"
But this syntax works just fine:
/tmp$ cat test.c
#include <stdio.h>
void fn(void f(void))
{
f();
f();
}
void g(void)
{
puts("g");
}
int main()
{
fn(g);
return 0;
}
/tmp$ gcc test.c
/tmp$ ./a.out
g
ghttps://developer.apple.com/library/ios/documentation/cocoa/...
(For bonus points, make it output a legal COBOL programme.)
"Foo a" declares a of type Foo (whatever that is), but cdecl says Syntax Error.
It does not even work with C99 types. "bool a", "_Bool a", "int32_t a" all give Syntax Error.