Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cornell!uw-beaver!mit-eddie!bu-cs!buengc!bph From: bph@buengc.BU.EDU (Blair P. Houghton) Newsgroups: comp.lang.c Subject: Re: function casting Message-ID: <2723@buengc.BU.EDU> Date: 30 Apr 89 08:59:05 GMT References: <12481@umn-cs.CS.UMN.EDU> Reply-To: bph@buengc.bu.edu (Blair P. Houghton) Followup-To: comp.lang.c Organization: Boston Univ. Col. of Eng. Lines: 51 In article <12481@umn-cs.CS.UMN.EDU> clark@umn-cs.CS.UMN.EDU (Robert P. Clark) writes: > >main() >{ > int (*f)(); It's alright, so far... > char *foo(); > > > f = ((*int)())foo(); /* foo returns char*, but I know this is */ > /* really an address of a function */ Bad declaration-to-cast conversion... You want merely to remove the identifier when doing a cast, rather that rearranging anything. The declaration int (*f)(); becomes a cast, therefore, by excising the "f" and the ";" and pre-/ap-pending "(" and ")". f = ( int (*)() ) foo(); >} There are programs out there that do it. If you really want to know, by doing f = ((*int)())... You're trying to call a function pointed-to by a thing called 'int' which is a C keyword, and therefore will generate all sorts of syntactical trouble in the situation you've placed it. PLUG ALERT! Andrew Koenig's _C Traps and Pitfalls_ handles this about as well as it can be handled... GO BACK TO YOUR HOMES, THERE'S NOTHING LEFT TO BE BOUGHT, HERE... --Blair "Do I get a free copy of ed. 2, now, huh, Andy, huh, do I do I do I ?? :-)"