Call of non-function (?)

Steven List itkin at luke.UUCP
Fri Dec 20 07:03:21 AEST 1985


In article <1155 at bbnccv.UUCP> ptraynor at bbnccv.UUCP (Patrick Traynor) writes:
>While trying to compile some source code that I got over the net, my compiler
>tripped over this line:
>
>cmd->c_func(args, arg1, arg2, got1, got2);
>
>In fact, at several points in the code, similar lines made the compiler throw
>up.  The error was 'call of non-function'.

I am making a couple of assumptions: cmd is a pointer to a structure AND
that structure contains an element of the form:

	int (*c_func)();

If that is so, you've just run into something I've just finished
wrestling with.  The proper invocation of the function is:

	(*cmd->c_func)(args, arg1, arg2, got1, got2);

It is important to remember that the structure element is "a pointer to
a function returning an integer".  Thus you must use the contents of
that element, not the element, to invoke the function.  The parentheses
assure the proper evaluation of the statement (I tried it without and
got the wrong result - it tries to take the contents of the return from
the function or something).

If anyone else can clarify this further, please do so.
-- 
***
*  Steven List @ Benetics Corporation, Mt. View, CA
*  Just part of the stock at "Uncle Bene's Farm"
*  {cdp,engfocus,greipa,idi,oliveb,plx,sun,tolerant}!bene!luke!itkin
***



More information about the Comp.sources.bugs mailing list