Skip to content

Commit 16ef60f

Browse files
committed
Updated CODECONVENTIONS to clarify use of integer types.
1 parent b026134 commit 16ef60f

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

CODECONVENTIONS.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,17 @@ Header files:
4040
Type names and declarations:
4141
- When defining a type, put '_t' after it.
4242

43+
Integer types: Micro Python runs on 32 and 64 bit machines (and one day
44+
maybe 16 bit), so it's important to use the correctly-sized (and signed)
45+
integer types. The general guidelines are:
46+
- For most cases use mp_int_t for signed and mp_uint_t for unsigned
47+
integer values. These are guaranteed to be machine-word sized and
48+
therefore big enough to hold the value from a Micro Python small-int
49+
object.
50+
- Use size_t for things that count bytes / sizes of objects.
51+
- You can use int/uint, but remember that they may be 16-bits wide.
52+
- If in doubt, use mp_int_t/mp_uint_t.
53+
4354
Examples
4455
--------
4556

0 commit comments

Comments
 (0)