Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!rutgers!sri-spam!ames!oliveb!sun!gorodish!guy From: guy%gorodish@Sun.COM (Guy Harris) Newsgroups: comp.lang.c Subject: Re: Function prototypes versus open() Message-ID: <20119@sun.uucp> Date: Mon, 1-Jun-87 15:49:44 EDT Article-I.D.: sun.20119 Posted: Mon Jun 1 15:49:44 1987 Date-Received: Wed, 3-Jun-87 01:40:03 EDT References: <18346@ucbvax.BERKELEY.EDU> <8042@utzoo.UUCP> <2210@hoptoad.uucp> <931@wjvax.wjvax.UUCP> Sender: news@sun.uucp Lines: 50 > How about functions called with function pointers? I am not that familiar > with the details of function prototyping in the standard, but will it be > possible to invoke functions with variable arguments with function pointers? From the October 1, 1986 draft: 3.5.3.3 Function declarators (including prototypes) ... Here are two more intricate examples: int (*apfi[3])(int *x, int *y); declares an array "apfi" of three pointers to functions returning "int". Each of these functions has two parameters that are pointers to "int".... which implies that the type of a function pointer, just like the type of a function, includes the types of its arguments as well as the type of its result. As such, you can declare int (*pintvarargs)(int i, ...); which is a pointer to a function whose first argument is an "int" and which may have 0 or more optional arguments after that. A function pointed to by "pintvarargs" can be called with a variable-length list of arguments, as long as that list has at least one argument and the first argument is of a type that can be coerced to "int". The declaration int (*pintarg)(int i); declares a pointer to a function whose *only* argument is an "int". A function pointed to by "pintarg" may only be called with one argument, which must be of a type that can be coerced to "int". The deprecated old-style declaration int (*pwhoknows)(); is, I infer, equivalent to int (*pwhoknows)(...); which declares a pointer to a function which may have 0 or more optional arguments. Guy Harris {ihnp4, decvax, seismo, decwrl, ...}!sun!guy guy@sun.com