Function-types: compatability, and typedefs

Walter Murray walter at hpclwjm.HP.COM
Wed Sep 6 03:50:54 AEST 1989


A couple of differing viewpoints to the responses Doug posted:

(I haven't been able to mail to the author of the basenote.)

>>    extern int example( MonadicStringFunction arg );
>>Would I need to add the * to ensure the argument is treated as a function 
>>pointer...

>I think so.  You want a pointer to a function, you should declare it as such.
>The automatic conversion of identifier designating a function to a pointer
>occurs only in expressions, not in declarations.  

As I read the dpANS, the * is not necessary.  There is an adjustment that
occurs in function declarations and definitions, analogous to the
automatic conversion that occurs in expressions.  See 3.5.4.3 and 3.7.1. 
(In the dpANS of 12/7/88, see page 69, lines 22-24, and page 83,
lines 23-26.)

>>Can I also use the typedef in a *definition*:
>>    MonadicStringFunction boring( char *arg ) { return arg; }

>With the first (non-pointer) typedef, you're supposed to be able to.

I don't think so, if I am understanding the question right.  It is
forbidden by a constraint in 3.7.1.  See footnote 76 on page 82.

Walter Murray
----------



More information about the Comp.lang.c mailing list