summaryrefslogtreecommitdiffstatshomepage
path: root/CODECONVENTIONS.md
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-09-23 18:20:00 +0100
committerDamien George <damien.p.george@gmail.com>2014-09-25 15:49:26 +0100
commit16ef60fba6b8517bf6b6f71c19ae6baa44a3f9af (patch)
tree4f529e8b98c5c49b80f80181d5d977369111855d /CODECONVENTIONS.md
parentb0261341d3706329ea58d8fc1a5ff9c788c9ccf7 (diff)
downloadmicropython-16ef60fba6b8517bf6b6f71c19ae6baa44a3f9af.tar.gz
micropython-16ef60fba6b8517bf6b6f71c19ae6baa44a3f9af.zip
Updated CODECONVENTIONS to clarify use of integer types.
Diffstat (limited to 'CODECONVENTIONS.md')
-rw-r--r--CODECONVENTIONS.md11
1 files changed, 11 insertions, 0 deletions
diff --git a/CODECONVENTIONS.md b/CODECONVENTIONS.md
index c8dbdae3d3..5aed89ae88 100644
--- a/CODECONVENTIONS.md
+++ b/CODECONVENTIONS.md
@@ -40,6 +40,17 @@ Header files:
Type names and declarations:
- When defining a type, put '_t' after it.
+Integer types: Micro Python runs on 32 and 64 bit machines (and one day
+maybe 16 bit), so it's important to use the correctly-sized (and signed)
+integer types. The general guidelines are:
+- For most cases use mp_int_t for signed and mp_uint_t for unsigned
+ integer values. These are guaranteed to be machine-word sized and
+ therefore big enough to hold the value from a Micro Python small-int
+ object.
+- Use size_t for things that count bytes / sizes of objects.
+- You can use int/uint, but remember that they may be 16-bits wide.
+- If in doubt, use mp_int_t/mp_uint_t.
+
Examples
--------