Re: More questions about casting function pointers ..



Alfonso Morra wrote:
>
> typedef void (*VFP)(void) ;
> typedef int(MyCallback*)(enum_1, enum2, int, void*) ;
>
> I hav a struct as ff:
>
> typedef struct {
> VFP mini_callback ;
> VFP data_callback ;
> ...
> }FunctorStruct ;
>
> I can assign a function ptr of type MyCallback to mini_callback or
> data_callback (after suitable casts to VFP).
>
> Assuming i have function foo defined as ff:
>
> int foo( FunctorStruct *fctor ) {
> /* code here to call function pointed to by data_callback
> assuming we know the function pointed to is of type
> MyCallback */
>
> (MyCallback)fctor->data_callback( ONE, TWO, 100, NULL ) ; /* <- dosen't
> compile !*/

((MyCallback) fctor->data_callback)( ONE, TWO, 100, NULL ) ;

> }

--
Peter

.