Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!rutgers!sri-spam!mordor!lll-tis!ames!oliveb!sun!gorodish!guy From: guy%gorodish@Sun.COM (Guy Harris) Newsgroups: comp.lang.c Subject: Re: Function prototypes versus open() Message-ID: <22196@sun.uucp> Date: Fri, 26-Jun-87 15:33:08 EDT Article-I.D.: sun.22196 Posted: Fri Jun 26 15:33:08 1987 Date-Received: Sat, 27-Jun-87 10:53:25 EDT References: <18346@ucbvax.BERKELEY.EDU> <8042@utzoo.UUCP> <2210@hoptoad.uucp> <817@mcgill-vision.UUCP> Sender: news@sun.uucp Lines: 35 > Except that this makes it effectively impossible to use the dispatcher. > Consider the call to the dispatcher that would have been written (under > the old K&R paradigm) as > > int fxn(); > ... > dispatcher(....,fxn); > > How does on write the corresponding thing? /* * This would presumably appear in an #include file. */ typedef union { int (*three_argument)(int, int, double); int (*four_argument)(int, int, double, double); int (*five_argument)(int, int, double, double, double); } function_pointer_passed_to_dispatcher; int fxn(int x; int y; double z); extern return_type_of_dispatcher dispatcher(various_argument_types, function_pointer_passed_to_dispatcher funcp); function_pointer_passed_to_dispatcher temporary; temporary.three_argument = fxn; dispatcher(..., temporary); Yes, this may be ugly, but it's type-correct, and may even be necessary in some implementations. Guy Harris {ihnp4, decvax, seismo, decwrl, ...}!sun!guy guy@sun.com