auvbarn@auvc5.tamu.edu (David Barnett) (12/13/90)
Is the following prototype legal in ANSI C? int foo(int a, int ); Saber-C 3.0 rejects this as an error: "The function parameter list has an illegal format". On the other hand, gcc 1.37 compiles it without so much as a warning, even when using -Wall -ansi -pedantic. I don't see anything in K&R2 that explicitly allows or prohibits this. Page 26 says "parameter names are optional in a function prototype", but in each of the examples, either all of the parameters have names or none do. What about the half-and-half case above? (I'm asking because prototypes of this form occur in a vendor-supplied .h file, and I need to know whether to complain to that vendor or to Saber-C.) -- David Barnett dbarnett@cs.tamu.edu -- David Barnett auvbarn@auvsun1.tamu.edu
gwyn@smoke.brl.mil (Doug Gwyn) (12/13/90)
In article <AUVBARN.90Dec12185342@auvc5.tamu.edu> auvbarn@auvc5.tamu.edu (David Barnett) writes: >Is the following prototype legal in ANSI C? >int foo(int a, int ); Yes, a strictly conforming program has the option of supplying identifiers for the prototype parameters or not, in any combination. This follows directly from the grammar.
henry@zoo.toronto.edu (Henry Spencer) (12/13/90)
In article <AUVBARN.90Dec12185342@auvc5.tamu.edu> auvbarn@auvc5.tamu.edu (David Barnett) writes: >Is the following prototype legal in ANSI C? > >int foo(int a, int ); Yes. Boy, is that ever a pain to parse, too. You have no idea. -- "The average pointer, statistically, |Henry Spencer at U of Toronto Zoology points somewhere in X." -Hugh Redelmeier| henry@zoo.toronto.edu utzoo!henry
karl@ima.isc.com (Karl Heuer) (12/14/90)
In article <AUVBARN.90Dec12185342@auvc5.tamu.edu> auvbarn@auvc5.tamu.edu (David Barnett) writes: >[Is `int foo(int a, int );' legal? Saber-C rejects it], and I need to know >whether to complain to [the header file's] vendor or to Saber-C.) Complain to both. Saber-C should accept it, since it's legal; and the vendor shouldn't be using it, because it's inferior to *both* alternatives. Karl W. Z. Heuer (karl@ima.isc.com or uunet!ima!karl), The Walking Lint