DEVELOPMENT EDITION · 769442725406
Library Reference
On this page
Package Interfaces.C
Interfaces.C (RM B.3): the C types of the platform (LP64: macOS and Linux on 64-bit machines) and the conversions between Ada strings and C character arrays.
int
type int is range -2 ** 31 .. 2 ** 31 - 1;short
type short is range -2 ** 15 .. 2 ** 15 - 1;long
type long is range -2 ** 63 .. 2 ** 63 - 1;signed_char
type signed_char is range -128 .. 127;unsigned
type unsigned is mod 2 ** 32;unsigned_short
type unsigned_short is mod 2 ** 16;unsigned_long
type unsigned_long is mod 2 ** 64;unsigned_char
type unsigned_char is mod 2 ** 8;size_t
type size_t is mod 2 ** 64;C_float
type C_float is digits 6;double
type double is digits 15;char
type char is new Character;nul
nul : constant char := char'First;To_C
function To_C (Item : Character) return char is (char (Item));To_Ada
function To_Ada (Item : char) return Character is (Character (Item));char_array
type char_array is array (size_t range <>) of char;To_C
function To_C (Item : String; Append_Nul : Boolean := True) return char_array
with Global => null,
Pre => Append_Nul or Item'Length > 0,
Post => To_C'Result'First = 0
and To_C'Result'Length = Item'Length + (if Append_Nul then 1 else 0)
and (if Append_Nul then To_C'Result (To_C'Result'Last) = nul);The characters of Item from index 0, then a nul unless Append_Nul is False
To_Ada
function To_Ada (Item : char_array; Trim_Nul : Boolean := True) return String
with Global => null,
Pre => (Item'Last < Item'First or else Item'Last - Item'First < size_t (Integer'Last) - 1)
and (if Trim_Nul then (for some I in Item'Range => Item (I) = nul)),
-- (from 1, and no longer than Item: RM B.3(44))
Post => To_Ada'Result'First = 1 and To_Ada'Result'Length <= Item'Length;The characters of Item up to its first nul (or all of them unless Trim_Nul is True)