Prototypes [was Re: Patch for bugs 772 and 17913]

Roger Sayle roger@eyesopen.com
Tue May 3 15:49:00 GMT 2005


On Tue, 3 May 2005, [ISO-8859-2] Gábor Lóki wrote:
> >>+static tree contains_label_1 (tree*, int*, void*);
> >>+static bool contains_label_p (tree);
> >
> > You only need to prototype the constains_label_p call, as it's
> > subroutine contains_label_1 is only used after it's defined.
> > If both these routines were moved earlier in fold-const.c, you
> > wouldn't need to prototype either.
>
> Of course, the prototype of 'contains_label_1' isn't necessary.
> Personally, I prefer using prototypes in this way, but I can remove it.


Richard Henderson recently stated his position on this issue in
http://gcc.gnu.org/ml/gcc-patches/2005-04/msg02907.html

	You'll say its needed for this decl, but this decl isn't needed
	due to function ordering.  Indeed, I make it a habit not to
	pre-declare anything unless forced.  I prefer functions to
	simply be ordered such that the decls aren't needed.

Whilst, to my knowledge, no official position has yet been taken on the
preferred GCC style, RTH's position eliminates the arbitraryness with
GCC's current style.  There are currently both lots of prototypes that
aren't strictly needed, and lots of functions without prototypes.  A
decision to minimize prototypes (and prefer function ordering) also has
maintenance benefits, as we probably still have many prototypes for
functions that have long since been deleted, and theoretically even
unconditional prototypes that don't match conditionally compiled
function declarations.

Perhaps the discussion should be opened to wider debate, ratified
and then documented in http://gcc.gnu.org/codingconventions.html ?
Admittedly, this document is some what out of date, as it doesn't
describe GCC's decision to move to C89/C90 and the default authority
http://www.gnu.org/prep/standards/standards.html still recommends
using K&R style function declarations and PARAMS-like macros in
function prototypes, which have recently been abandoned by the GCC
project:  http://www.gnu.org/prep/standards/standards.html#Standard-C

Roger
--



More information about the Gcc-patches mailing list