This is the mail archive of the
mailing list for the GCC project.
Prototypes [was Re: Patch for bugs 772 and 17913]
- From: Roger Sayle <roger at eyesopen dot com>
- To: Gábor Lóki <loki at inf dot u-szeged dot hu>
- Cc: Mark Mitchell <mark at codesourcery dot com>, "Joseph S. Myers" <joseph at codesourcery dot com>, <gcc-patches at gcc dot gnu dot org>, Richard Henderson <rth at redhat dot com>
- Date: Tue, 3 May 2005 09:49:18 -0600 (MDT)
- Subject: Prototypes [was Re: Patch for bugs 772 and 17913]
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
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
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