diff options
author | Russell Belfer <rb@github.com> | 2014-02-20 11:26:51 -0800 |
---|---|---|
committer | Russell Belfer <rb@github.com> | 2014-02-20 11:26:51 -0800 |
commit | 68a19ca9ffb685123038a8d16c0a59845f147778 (patch) | |
tree | 6fc61ee4886564670fc45f32a7d7f62f1712ff4d /CONVENTIONS.md | |
parent | 978a4ed5ebd3892731434e4023f20383f820c112 (diff) | |
download | libgit2-68a19ca9ffb685123038a8d16c0a59845f147778.tar.gz |
Clarify C compatibility policy
and a couple of other minor doc fixups.
Diffstat (limited to 'CONVENTIONS.md')
-rw-r--r-- | CONVENTIONS.md | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/CONVENTIONS.md b/CONVENTIONS.md index 59b41a2e6..5b8238a78 100644 --- a/CONVENTIONS.md +++ b/CONVENTIONS.md @@ -6,14 +6,18 @@ guidelines that should help with that. ## Compatibility `libgit2` runs on many different platforms with many different compilers. -It is written in [ANSI C](http://en.wikipedia.org/wiki/ANSI_C) (a.k.a. C89) -with some specific standards for function and type naming, code formatting, -and testing. -We try to avoid more recent extensions to maximize portability. We also, to -the greatest extent possible, try to avoid lots of `#ifdef`s inside the core -code base. This is somewhat unavoidable, but since it can really hamper -maintainability, we keep it to a minimum. +The public API of `libgit2` is [ANSI C](http://en.wikipedia.org/wiki/ANSI_C) +(a.k.a. C89) compatible. + +Internally, `libgit2` is written using a portable subset of C99 - in order +to maximize compatibility (e.g. with MSVC) we avoid certain C99 +extensions. Specifically, we keep local variable declarations at the tops +of blocks only and we avoid `//` style comments. + +Also, to the greatest extent possible, we try to avoid lots of `#ifdef`s +inside the core code base. This is somewhat unavoidable, but since it can +really hamper maintainability, we keep it to a minimum. ## Match Surrounding Code @@ -209,6 +213,9 @@ All inlined functions must be declared as: GIT_INLINE(result_type) git_modulename_functionname(arg_list); ``` +`GIT_INLINE` (or `inline`) should not be used in public headers in order +to preserve ANSI C compatibility. + ## Tests `libgit2` uses the [clar](https://github.com/vmg/clar) testing framework. |