]> git.ipfire.org Git - thirdparty/git.git/commitdiff
CodingGuidelines: mention "static" and "extern"
authorJeff King <peff@peff.net>
Thu, 8 Feb 2018 21:38:06 +0000 (16:38 -0500)
committerJunio C Hamano <gitster@pobox.com>
Thu, 8 Feb 2018 22:20:43 +0000 (14:20 -0800)
It perhaps goes without saying that file-local stuff should
be marked static, but it does not hurt to remind people.

Less obvious is that we are settling on "do not include
extern in function declarations". It is already the default
unless the function was previously declared static (but if
you are following a static declaration with an unmarked one,
you should think about why you are declaring the thing
twice). And so it just becomes an extra noise-word in our
header files.

We used to give the opposite advice, so there are quite a
few "extern" markers in early Git code. But this at least
makes a concrete suggestion that we can follow going
forward.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/CodingGuidelines

index c4cb5ff0d477938b8fd49749c3589c5afbb04221..48aa4edfbdd180e1c6d874b6bb61ea5fc8e32ef5 100644 (file)
@@ -386,6 +386,11 @@ For C programs:
  - Use Git's gettext wrappers to make the user interface
    translatable. See "Marking strings for translation" in po/README.
 
+ - Variables and functions local to a given source file should be marked
+   with "static". Variables that are visible to other source files
+   must be declared with "extern" in header files. However, function
+   declarations should not use "extern", as that is already the default.
+
 For Perl programs:
 
  - Most of the C guidelines above apply.