double pointer to function

Stergios Marinopoulos stergios at athsys.uucp
Sun Aug 7 13:36:24 AEST 1988


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
second I write   code like this, it's  the  ouput of  a C++ translator
considerably simplified and cleaned up.


struct A { int (**A_tablePtr )(); } ;

void A_c ();
void A_d () ;

static int (*A__vtbl[])() = { (int(*)()) A_d , 0 };


typedef void (**PMF )();

extern int function1() ;
extern int function2() ;

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 ) ;


  /* my hack to get it compiling */
  /* no problems */

  (**(
     (void (**)()) ( flag ?
		   ((void (**)())pmf )
		   :
		   (void (**)())(&(this -> A_tablePtr [(((unsigned int )(*(((void (**)())pmf ))))) - 1]))
		   )
     )
   )
    ( this ) ;
  
  
}



stergios marinopoulos
sun!athsys!stergios



More information about the Comp.lang.c mailing list