Xref: utzoo comp.lang.c:27725 gnu.gcc:1540 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!dali!cambridge.apple.com!bloom-beacon!shelby!mcnc!duke!romeo!drh From: drh@romeo.cs.duke.edu (D. Richard Hipp) Newsgroups: comp.lang.c,gnu.gcc Subject: Re: How do I cast to "pointer to function returning int" ? Message-ID: <18834@duke.cs.duke.edu> Date: 10 Apr 90 13:10:53 GMT References: <6090.2621f6c2@csv.viccol.edu.au> Sender: news@duke.cs.duke.edu Reply-To: drh@romeo.UUCP (D. Richard Hipp) Organization: Duke University CS Dept.; Durham, NC Lines: 18 In article <6090.2621f6c2@csv.viccol.edu.au> timcc@csv.viccol.edu.au writes: >struct foo { > char *name ; > int (*function) () ; > } ; > >struct foo foo_table[] = { > "bar", (int * ()) bar, > "blurfl", (int * ()) blurfl, > "frobjitz", (int * ()) frobjitz, > } ; The typecast (int *()) is for "function returning pointer to integer". To get "pointer to function returning integer" use (int (*)()). The rule is this: operators on the right hand side bind tighter than operators on the left hand side. Thus "()" binds tighter than "*". You want the "*" to bind closest, so the extra parenthesis are required.