Re: argument names in function declarations

Luke Mewburn <[email protected]> Tue, 25 Aug 2009 14:26:17 +1000
Newsgroups gmane.os.netbsd.devel.general
Message-ID <[email protected]>
On Tue, Aug 25, 2009 at 02:44:00AM +0000, David Holland wrote:
  | The style rules currently prohibit argument names in function
  | declarations. This is necessary for installed headers, because
  | otherwise legal but stupid things the user can do with cpp can cause
  | the declarations to blow up.
  | 
  | However, outside of that context, argument names, or at least some
  | argument names, serve as a useful form of documentation. While the
  | "vp" in "struct vnode *vp" doesn't add much value, writing "unsigned
  | flags" instead of just "unsigned" is actually useful, and IMO it
  | should be, if anything, encouraged.
  | 
  | Is this a good/bad idea? Should I propose specific text for
  | share/misc/style?

I name prototype arguments where appropriate, for similar reasons
to your example of "unsigned flags".  I've used a variety of
naming conventions, depending upon the local conventions.
Sometimes knowing whether an argument is an "in" versus "out"
versus "both" can be useful, although you can usually infer that
a variable is input-only if it has const.

Does using leading underscores in the names help with the cpp issue?


Luke.
signature.asc (application/pgp-signature, 194 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (NetBSD)

iEYEARECAAYFAkqTZ+kACgkQpBhtmn8zJHIgAwCfUhHIyYhRZx9nltb5GJNlg7Qf
I2YAn0I+aj987Gv99C3wx2/qUNvwsFRd
=xFbm
-----END PGP SIGNATURE-----