platform/c
Target scope is enforced by the module assertion below.
C scalar aliases selected by the supported LP64 ABI.
The aliases preserve ordinary Landin scalar identity. Plain C char follows the selected ABI, rather than assuming signedness from pointer width. The source assertion and conditional signatures show the exact supported scope; Cortex-M C signatures are not admitted by this module.
compiler.assert(compiler.c_sysv_lp64 or compiler.c_darwin_lp64
or compiler.c_aapcs64_lp64 or compiler.c_riscv_lp64d)Items
- c_bool type
- c_char type
- c_double type
- c_float type
- c_int type
- c_long type
- c_longlong type
- c_ptrdiff type
- c_schar type
- c_short type
- c_size type
- c_uchar type
- c_uint type
- c_ulong type
- c_ulonglong type
- c_ushort type
Executable example
This complete program is maintained in the repository runtime tests. View source.
import platform/c import platform/c (c_bool, c_double, c_float, c_long, c_longlong, c_ptrdiff, c_size, c_ulong, c_ulonglong) public main: () -> (code: i32) = -- c_char is deliberately a signed numeric byte, not Unicode u32. character: c.c_char = -1 signed_character: c.c_schar = -2 unsigned_character: c.c_uchar = 255 short_value: c.c_short = -123 unsigned_short: c.c_ushort = 456 integer: c.c_int = -789 unsigned_integer: c.c_uint = 987 long_value: c.c_long = c_long(integer) unsigned_long: c.c_ulong = c_ulong(unsigned_integer) long_long: c.c_longlong = c_longlong(long_value) unsigned_long_long: c.c_ulonglong = c_ulonglong(unsigned_long) size: c.c_size = c_size(24) difference: c.c_ptrdiff = c_ptrdiff(-24) single: c.c_float = c_float(3) double: c.c_double = c_double(single) truth: c.c_bool = c_bool(1) -- Alias identity permits these ordinary assignments without adapters. ordinary_character: i8 = character ordinary_short: i16 = short_value ordinary_integer: i32 = integer ordinary_long: i64 = long_value ordinary_unsigned_character: u8 = unsigned_character ordinary_unsigned_short: u16 = unsigned_short ordinary_unsigned_integer: u32 = unsigned_integer ordinary_unsigned_long: u64 = unsigned_long ordinary_size: usize = size ordinary_difference: isize = difference ordinary_single: f32 = single ordinary_double: f64 = double ordinary_truth: bool = truth if sizeof c.c_char == 1 and alignof c.c_char == 1 and sizeof c.c_schar == 1 and alignof c.c_schar == 1 and sizeof c.c_uchar == 1 and alignof c.c_uchar == 1 and sizeof c.c_short == 2 and alignof c.c_short == 2 and sizeof c.c_ushort == 2 and alignof c.c_ushort == 2 and sizeof c.c_int == 4 and alignof c.c_int == 4 and sizeof c.c_uint == 4 and alignof c.c_uint == 4 and sizeof c.c_long == 8 and alignof c.c_long == 8 and sizeof c.c_ulong == 8 and alignof c.c_ulong == 8 and sizeof c.c_longlong == 8 and alignof c.c_longlong == 8 and sizeof c.c_ulonglong == 8 and alignof c.c_ulonglong == 8 and sizeof c.c_size == 8 and alignof c.c_size == 8 and sizeof c.c_ptrdiff == 8 and alignof c.c_ptrdiff == 8 and sizeof c.c_float == 4 and alignof c.c_float == 4 and sizeof c.c_double == 8 and alignof c.c_double == 8 and sizeof c.c_bool == 1 and alignof c.c_bool == 1 and ordinary_character == -1 and ordinary_short == -123 and ordinary_integer == -789 and ordinary_long == -789 and ordinary_unsigned_character == 255 and ordinary_unsigned_short == 456 and ordinary_unsigned_integer == 987 and ordinary_unsigned_long == 987 and long_long == -789 and unsigned_long_long == 987 and ordinary_size == 24 and ordinary_difference == -24 and ordinary_single == 3.0 and ordinary_double == 3.0 and ordinary_truth then code = 42 else code = 1 end if end main
c_bool type
public c_bool: type = boolAlias for C _Bool under the supported LP64 ABIs.
c_char type
When compiler.c_aapcs64_lp64 or compiler.c_riscv_lp64d
public c_char: type = u8The selected ABI's plain C char: unsigned under standard AAPCS64 and RISC-V LP64D, signed under SysV and Darwin LP64. A numeric byte, not a Unicode scalar.
When not (compiler.c_aapcs64_lp64 or compiler.c_riscv_lp64d)
public c_char: type = i8The selected ABI's plain C char: unsigned under standard AAPCS64 and RISC-V LP64D, signed under SysV and Darwin LP64. A numeric byte, not a Unicode scalar.
c_double type
public c_double: type = f64Alias for C double under the supported LP64 ABIs.
c_float type
public c_float: type = f32Alias for C float under the supported LP64 ABIs.
c_int type
public c_int: type = i32Alias for C signed int under the supported LP64 ABIs.
c_long type
public c_long: type = i64Alias for C signed long under the supported LP64 ABIs.
c_longlong type
public c_longlong: type = i64Alias for C signed long long under the supported LP64 ABIs.
c_ptrdiff type
public c_ptrdiff: type = isizeAlias for C ptrdiff_t under the supported LP64 ABIs.
c_schar type
public c_schar: type = i8Alias for C signed char under the supported LP64 ABIs.
c_short type
public c_short: type = i16Alias for C signed short under the supported LP64 ABIs.
c_size type
public c_size: type = usizeAlias for C size_t under the supported LP64 ABIs.
c_uchar type
public c_uchar: type = u8Alias for C unsigned char under the supported LP64 ABIs.
c_uint type
public c_uint: type = u32Alias for C unsigned int under the supported LP64 ABIs.
c_ulong type
public c_ulong: type = u64Alias for C unsigned long under the supported LP64 ABIs.
c_ulonglong type
public c_ulonglong: type = u64Alias for C unsigned long long under the supported LP64 ABIs.
c_ushort type
public c_ushort: type = u16Alias for C unsigned short under the supported LP64 ABIs.