Difference between revisions of "Types"
From MSX Game Library
Line 7: | Line 7: | ||
! Type !! Desc. !! [[SDCC]] equivalent !! Min value !! Max value | ! Type !! Desc. !! [[SDCC]] equivalent !! Min value !! Max value | ||
|- | |- | ||
− | | '''<tt>bool</tt>''' || Boolean (8 bits) || <tt>unsigned char</tt> || 0 || [[Boolean|not 0]] | + | | '''<tt>bool</tt>''' || [[Boolean]] (8 bits) || <tt>unsigned char</tt> || 0 || [[Boolean|not 0]] |
|- | |- | ||
| '''<tt>i8</tt>''' || 8 bits signed integer || <tt>signed char</tt> || -128 || 127 | | '''<tt>i8</tt>''' || 8 bits signed integer || <tt>signed char</tt> || -128 || 127 |
Latest revision as of 17:40, 24 March 2024
You can use standard C types to define variables but MSXgl provide some shortcut that help to write short code and makes data size and sign explicit (which is so important for creating efficient code on a Z80).
MSXgl's types can be found in core.h.
Type | Desc. | SDCC equivalent | Min value | Max value |
---|---|---|---|---|
bool | Boolean (8 bits) | unsigned char | 0 | not 0 |
i8 | 8 bits signed integer | signed char | -128 | 127 |
u8 | 8 bits unsigned integer | unsigned char | 0 | 255 |
i16 | 16 bits signed integer | signed short | -32768 | 32767 |
u16 | 16 bits unsigned integer | unsigned short | 0 | 65535 |
i32 | 32 bits signed integer | signed long | -2,147,483,648 | 2,147,483,647 |
u32 | 32 bits unsigned integer | unsigned long | 0 | 4,294,967,295 |
i64 | 64 bits signed integer | signed long long | -9,223,372,036,854,775,808 | 9,223,372,036,854,775,807 |
u64 | 64 bits unsigned integer | unsigned long long | 0 | 18,446,744,073,709,551,615 |
f32 | 32 bits float (IEEE 754) | float | 1,175494351e-38 | 3,402823466e+38 |
c8 | 8 bits character (ASCII, UTF-8) | unsigned char | 0 | 255 |
c16 | 16 bits character (UTF-16, JIS, etc.) | unsigned short | 0 | 65535 |
ptr | Pointer | void* | 0x0000 | 0xFFFF |
callback | Callback default signature | void (*)(void) |
Related constants:
#define NULL 0 // Pointer "NULL" value #define TRUE 1 // Value for "TRUE" boolean #define FALSE 0 // Value for "FALSE" boolean
See also:
- Page about usage of boolean in MSXgl.
- SDCC documentation