Xref: utzoo comp.lang.c:11744 comp.lang.c++:1404 Path: utzoo!attcan!uunet!husc6!uwvax!oddjob!mimsy!chris From: chris@mimsy.UUCP (Chris Torek) Newsgroups: comp.lang.c,comp.lang.c++ Subject: Re: double pointer to function Message-ID: <12885@mimsy.UUCP> Date: 7 Aug 88 22:05:12 GMT References: <107@cyclopes.UUCP> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 41 In article <107@cyclopes.UUCP> stergios@athsys.uucp (Stergios Marinopoulos) writes: >Can anyone figure out why the following code does not compile >correctly? The first ?/: pair makes cc (sun 3.4) complain .... >[(This is] the ouput of a C++ translator [).] Sun's compiler is correct to complain. Retaining only the relevant code, and deleting various unnecessary parentheses: >struct A { int (**A_tablePtr)(); }; > struct A *this ; > void *pmf ; > extern int flag ; > flag ? *(void (**)())pmf : > this->A_tablePtr[(unsigned int)*(void (**)())pmf) - 1] Examine the types of the objects on each side of the `:': *(void (**)())pmf => cast pmf to pointer to pointer to function returning void then indirect, so type is pointer to function returning void this->A_tablePtr[ ] => subscript (indirect) an object of type pointer to pointer to function returning int so type is pointer to function returning int Both are pointers to functions, but one returns void, the other int. For the expressions to be compatible, either the ?: line must read flag ? *(int (**)())pmf : or the delcaration of `struct A' must read struct A { void (**A_tablePtr)(); }; -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@mimsy.umd.edu Path: uunet!mimsy!chris