Function typedefs have any use?

Kevin P. Fleming kpfleming@starnetworks.us
Sun Feb 6 18:35:00 GMT 2005


Gabriel Dos Reis wrote:
> "Kevin P. Fleming" <kpfleming@starnetworks.us> writes:
> 
> | Eljay Love-Jensen wrote:
> | 
> | > But the syntax of C doesn't have the language construct of "here's a
> | > label (identifier), here's the type of that label, and here's it's
> | > body".

<snip>

> You mean like this:
> 
>       typedef int F(int);
>       F f;      /* function "f" taking an int and returning an int. */

Yes, that's it, and it _does_ work :-)

typedef int F(int);

F f;

f(bar)
{
   return bar * bar;
}

int main()
{
   printf("%d\n", f(6));
}

Running this produces "36", as expected.

Thanks!



More information about the Gcc-help mailing list