This is the mail archive of the
mailing list for the GCC project.
Forward declaration style
- From: Oleg Endo <oleg dot endo at t-online dot de>
- To: gcc <gcc at gcc dot gnu dot org>
- Date: Sat, 14 Jun 2014 15:38:25 +0200
- Subject: Forward declaration style
- Authentication-results: sourceware.org; auth=none
I was always wondering why this the way it is. E.g. consider
/* Assemble the integer constant X into an object of SIZE bytes. ALIGN is
the alignment of the integer in bits. Return 1 if we were able to output
the constant, otherwise 0. If FORCE is nonzero the constant must
be outputable. */
extern bool assemble_integer (rtx, unsigned, unsigned, int);
Here the function abstract mentions some argument names which are absent
in the declaration. When reading/browsing/searching the GCC code base
this is really not helpful. One is forced to go to the implementation
of the function and read it. On top of that the actual function
implementations are often in totally different places (e.g. there is no
such thing as output.c).
In lots of other cases, the declarations in the headers don't have any
documentation at all. In the assemble_integer case it's duplicated in
output.h and varasm.c.
How about adding the argument names to the declarations in header files
and move function abstracts from implementation files to the header
files? I think this would make it easier to lookup stuff in the code.
What do you think?