To insert code, use the <code cpp>
tag.
SCREAMING_SNAKE_CASE
PascalCase
camelCase
Thou shalt in all of thy code let ye Allman's style brace indentation be used (i.e. braces should always be on their own line, no matter if struct
, if
, while
, etc.)
struct MyStruct { int32_t uselessField; uint16_t anotherUselessField; }
When defining fields of number type, you must use the types defined in stdint.h
:
Specifier | Signing | Bits | Bytes | Minimum Value | Maximum Value |
---|---|---|---|---|---|
int8_t | Signed | 8 | 1 | −27 which equals −128 | 27 − 1 which is equal to 127 |
uint8_t | Unsigned | 8 | 1 | 0 | 28 − 1 which equals 255 |
int16_t | Signed | 16 | 2 | −215 which equals −32,768 | 215 − 1 which equals 32,767 |
uint16_t | Unsigned | 16 | 2 | 0 | 216 − 1 which equals 65,535 |
int32_t | Signed | 32 | 4 | −231 which equals −2,147,483,648 | 231 − 1 which equals 2,147,483,647 |
uint32_t | Unsigned | 32 | 4 | 0 | 232 − 1 which equals 4,294,967,295 |
int64_t | Signed | 64 | 8 | −263 which equals −9,223,372,036,854,775,808 | 263 − 1 which equals 9,223,372,036,854,775,807 |
uint64_t | Unsigned | 64 | 8 | 0 | 264 − 1 which equals 18,446,744,073,709,551,615 |
Also, when defining pointer fields, the *
must be on the right-side:
uint32_t *fieldName;
instead of
uint32_t* fieldName;
Hex | Bit | Description |
---|---|---|
0x0001 | 0 | text |
0x0002 | 1 | text |
0x0004 | 2 | text |
0x0008 | 3 | text |
0x0010 | 4 | Example of double line |
Example of double line | ||
0x0020 | 5 | text |
0x0040 | 6 | text |
0x0080 | 7 | text |
Hex | Bit | Description |
---|---|---|
0x0001 | 0 | text |
0x0002 | 1 | text |
0x0004 | 2 | text |
0x0008 | 3 | text |
0x0010 | 4 | Example of double line |
Example of double line | ||
0x0020 | 5 | text |
0x0040 | 6 | text |
0x0080 | 7 | text |
0x0100 | 8 | text |
0x0200 | 9 | text |
0x0400 | 10 | text |
0x0800 | 11 | text |
0x1000 | 12 | text |
0x2000 | 13 | text |
0x4000 | 14 | text |
0x8000 | 15 | text |
Hex value | 0x8000 | 0x7F00 | 0x001F |
|||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Bit | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
Field | Field1 | Field2 | Field3 |