[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]

pointers to functions



hi
this mail is with refrence to my previous mail which goes like this

>i have few functions say a(), b() ,c() ...
>i want to call these functions, each within same statement seperated by comma.
>e.g 
> ( a() , b() , c() );
>the problem is -- i want to vary the number and ordering of these functions within that statement at run time.

one solution for this which comes to my mind is making array of pointers to functions. and changing the binding of pointers to function at runtime.
so if a[] is an array of pointers , i could write
  ( *a[0] ) () ,  ( *a[1] ) () , ( *a[2] ) () );
and i just need to change these pointers to execute different functions with different ordering and change the number by leaving array pointers NULL which are not required.

now i want to know --- what kind of array should a[] be.  would void *a[] suffice.  i tried it but failed.
the parameter types of functions differ so i cannot do something like
typedef void (*ptr)() ;  	and declare array of ptr.

i just have APUE -stevens and Linux 6.2 for reference 
 
thanks

-----------------------------
deepak

have a great day 

ICQ 30662394