double pointer to function
Leo de Wit
leo at philmds.UUCP
Mon Aug 8 20:16:10 AEST 1988
In article <107 at cyclopes.UUCP> stergios at 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.
More information about the Comp.lang.c
mailing list