3 ms·
This has some odd corner cases. "void f(void)" -> "declare f as function (void) returning void" "void fun(void)" -> "declare fun as function (void) returning
by JoshTriplett 13y ago
This has some odd corner cases.
"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
g
- nknighthb 13y agoNot sure what's going on with your second example, but that first one looks like an odd consequence of how a cdecl feature is implemented. cdecl doesn't just explain C declarations, it can also create them based on a more verbose pseudo-english language (the same one it spits out in response to being fed an actual C declaration, I believe). "func" is an alias for that language's reserved word "function".