Xref: utzoo comp.lang.c:11760 comp.lang.c++:1405 Path: utzoo!attcan!uunet!mcvax!philmds!leo From: leo@philmds.UUCP (Leo de Wit) Newsgroups: comp.lang.c,comp.lang.c++ Subject: Re: double pointer to function Message-ID: <577@philmds.UUCP> Date: 8 Aug 88 10:16:10 GMT References: <107@cyclopes.UUCP> Reply-To: leo@philmds.UUCP (Leo de Wit) Organization: Philips I&E DTS Eindhoven Lines: 45 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, while the |second one does not. The only difference between the two is where the |double pointer to functions get dereferenced. Don't think for a It is not the only difference. The second uses a cast for the second operand (the one after :) so that the types of both parts of the ?: expression are the same. |second I write code like this, it's the ouput of a C++ translator |considerably simplified and cleaned up. | | |struct A { int (**A_tablePtr )(); } ; [stuff deleted]...... |void A_c (this , pmf ) |struct A *this ; |void *pmf ; |{ | | extern int flag ; | | /* code ccxx produces and error message cc spits out */ | /* warning: illegal pointer combination: illegal types in : */ | (*( | (void (*)()) ( flag ? | (*((void (**)())pmf )) | : | (this -> A_tablePtr [(((unsigned int )(*(((void (**)())pmf ))))) - 1]) | ) | ) | ) | ( this ) ; The type of the first part of the ?: expression is different from the type of the second part (no, I don't want to spell it out 8-), so I think cc is correct to complain (see also K&R 7.13 about the conditional operator). In the second part (the 'hack') both parts are cast to (void (**)()) so there is no problem here. Leo.