CBFalconer <> writes:
> Clever Monkey wrote:
>> wrote:
>>
>>> Can someone please explain this function pointer declaration:
>>>
>>> float (* getptr (char opcode) ) (int, int);
>>>
>>> I'm confused by the syntax - I have not seen a function pointer
>>> with the extra parameter "char opcode" in the parentheses.
>>
>> Find a copy of "cdecl" and run it against this signature. Most
>> versions of the utility will describe, in English, what is going
>> on.
>>
>> I get "declare getptr as function that expects (opcode as char)
>> returning pointer to function that expects (int, int) returning
>> float;"
>
> I get 'parse error'.
So do I (actually "syntax error", not "parse error"), but the error
message goes away if I delete the parameter name "opcode":
% cdecl -V
Version:
@(#)cdecl.c 2.5 1/15/96
@(#)cdgram.y 2.2 3/30/88
@(#)cdlex.l 2.2 3/30/88
% cdecl
Type `help' or `?' for help
cdecl> explain float (* getptr (char opcode) ) (int, int)
syntax error
cdecl> explain float (* getptr (char) ) (int, int)
declare getptr as function (char) returning pointer to function (int, int) returning float
cdecl>
Perhaps different versions of cdecl handle this differently.
--
Keith Thompson (The_Other_Keith)
kst- <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"