home *** CD-ROM | disk | FTP | other *** search
Wrap
Newsgroups: comp.lang.c Path: sparky!uunet!portal!dfuller From: dfuller@portal.hq.videocart.com (Dave Fuller) Subject: Re: need to create a jump table Message-ID: <BxBq9L.4sM@portal.hq.videocart.com> Organization: VideOcart Inc. X-Newsreader: Tin 1.1 PL3 References: <1992Nov3.025210.27336@ryn.mro4.dec.com> Date: Sat, 7 Nov 1992 02:15:20 GMT Lines: 35 uyeno@subsys.enet.dec.com (Alice Uyeno) writes: : : Hi, : : I'm trying to develop a jump table. Actually, the scenario is that I have two jump tables. Depending on the value of a certain flag, I use one or the other. Each jump table consists of pointers to functions. I'm wondering if it is possible to have the functions with varying number of parameters. For example, if my jump table contains pointers to ErrorRoutine and ValidateCmd, where the prototypes for the routines are as follows: : : void ErrorRoutine(int *ErrCode, struct foo * MyPtr); : void ValidateCmd(struct foo * CmdPtr); : : void (* FcnTbl[])() = {ErrorRoutine,ValidateCmd}; : : where : ptr = FcnTbl; : : and ptr is how the jump table is referenced. Alice, I would like to help you, but i don't have enough information, also i think i am slightly confused. you said that you have jump tables (plural), but i only see a definition for 1 function table. if you really have 2 function tables then it would be ok to have different # of parameters, but with 1 table it gets sort of impossible. if it were allowed, you would have to test the value of the function pointer to know how many parameters to pass. this is ugly also. if all of the pointed to functions took the same number of parameters this would be simple. maybe you need to modify the ideas behind this, maybe i just dont see well enough into this to solve it. If you are willing to give more specific info, i'd be glad to try to help. Dave Fuller dfuller@portal.hq.videocart.com