A question on Function declaration
Stan Brown
browns at iccgcc.decnet.ab.com
Thu Feb 14 07:04:24 AEST 1991
In article <5807 at marble.UUCP>, sland at motcid.UUCP (Stephen Shortland) writes:
> joshi at motcid.UUCP (Abhay B. Joshi) writes:
>
>>I would like to declare a function which returns a pointer to a function
>>(that returns an integer). I have been unable to strike at the correct
>>syntax of such a declaration.
>
>>I tried the following (among others):
>> ((int *)()) func() ;
>>Doesn't work.
I'm just a wussy little fraidy-cat (TM), so I do it in stages. You don't
say what arguments either of the functions takes, so I'll assume one
takes a char * and the other takes a double.
A function that takes a char * and returns an int is 'int func(char *);'.
Its type might be called 'FC_I':
typedef int FC_I(char *);
A pointer to such a function would be a 'FC_I *'. So a function that
takes a double and returns such a pointer would be
FC_I *desired_func(double);
This goes in two steps, unlike the other solutions I've seen. But
it's imposible to get the parentheses wrong with this method.
Comments from anyone? Disadvantages I've missed?
Hey--this is all my opinion, nobody else's. Rely on it at your peril.
email: browns at iccgcc.decnet.ab.com
Stan Brown, Oak Road Systems, Cleveland, Ohio, USA +1 216 371 0043
More information about the Comp.lang.c
mailing list