aboutsummaryrefslogtreecommitdiff
path: root/doc/coding.txt
diff options
context:
space:
mode:
authorGavin Andresen <gavinandresen@gmail.com>2011-05-09 14:04:24 -0400
committerGavin Andresen <gavinandresen@gmail.com>2011-05-09 14:04:24 -0400
commit91b8932eb1ff3a68d0d1e57bb43eaee3a6525f8b (patch)
tree13ebdb6bd67fae95fc30b6f76cdfd7cbe9971cce /doc/coding.txt
parent59d18adc4c2aaa5f24882e6c0cbeb43b47d80a80 (diff)
parentb17be7e14b4a62b7935c75fe7e7645e736fd68d2 (diff)
downloadbitcoin-91b8932eb1ff3a68d0d1e57bb43eaee3a6525f8b.tar.xz
Merge branch 'master' of github.com:bitcoin/bitcoin
Diffstat (limited to 'doc/coding.txt')
-rw-r--r--doc/coding.txt41
1 files changed, 41 insertions, 0 deletions
diff --git a/doc/coding.txt b/doc/coding.txt
new file mode 100644
index 0000000000..4707476697
--- /dev/null
+++ b/doc/coding.txt
@@ -0,0 +1,41 @@
+Please be consistent with the existing coding style.
+
+Block style:
+
+bool Function(char* psz, int n)
+{
+ // Comment summarising what this section of code does
+ for (int i = 0; i < n; i++)
+ {
+ // When something fails, return early
+ if (!Something())
+ return false;
+ ...
+ }
+
+ // Success return is usually at the end
+ return true;
+}
+
+- ANSI/Allman block style
+- 4 space indenting, no tabs
+- No extra spaces inside parenthesis; please don't do ( this )
+- No space after function names, one space after if, for and while
+
+Variable names begin with the type in lowercase, like nSomeVariable.
+Please don't put the first word of the variable name in lowercase like
+someVariable.
+
+Common types:
+n integer number: short, unsigned short, int, unsigned int,
+ int64, uint64, sometimes char if used as a number
+d double, float
+f flag
+hash uint256
+p pointer or array, one p for each level of indirection
+psz pointer to null terminated string
+str string object
+v vector or similar list objects
+map map or multimap
+set set or multiset
+bn CBigNum