Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!rutgers!ames!oliveb!sun!gorodish!guy From: guy@gorodish.UUCP Newsgroups: comp.lang.c Subject: Re: Function prototypes versus open() Message-ID: <20538@sun.uucp> Date: Sat, 6-Jun-87 16:03:54 EDT Article-I.D.: sun.20538 Posted: Sat Jun 6 16:03:54 1987 Date-Received: Sun, 7-Jun-87 10:24:37 EDT References: <18346@ucbvax.BERKELEY.EDU> <8042@utzoo.UUCP> <2210@hoptoad.uucp> <1569@stb.UUCP> Sender: news@sun.uucp Lines: 19 > Wait a sec. Would you please explain how the following can be done: > > I have a dispatcher routine, that takes a pointer to a function, some args, > does some munching on the args, and calls the pointed to routine with 3, > 4, or 5 args. Each routine called is expecting a known, fixed # of args, > yet the pointer used is with variable args. So, according to the above, > I have to declare the function pointer as variable args, which activates > one calling convention, yet the routines are fixed args, and expecting > another calling convention. Trivial. Have the argument to the dispatcher, instead of being a pointer to a function with a variable number of arguments, be a union of a pointer to a function with three arguments, a pointer to a function with four arguments, and a pointer to a function with five arguments. Since you have three separate calls, use the three different members of the union in the three calls. End of problem. Guy Harris {ihnp4, decvax, seismo, decwrl, ...}!sun!guy guy@sun.com