DEVELOPMENT EDITION · 769442725406
Library Reference
On this page

Interfaces.C

The supplied LP64 C types and Character/String conversions.

Read the family guide for representation, selection and resource rules. The complete declaration page retains exact signatures/contracts; the source specification is the implementation baseline.

Availability and ownership

An array passed to C is a pointer, with no bounds: pass the length separately. To_C appends nul by default; To_Ada with trimming requires a nul.

A client proof uses these contracts without proving the body again (see library assurance). Global => null excludes package-global effects, not changes made through an in out argument.

Import and instantiate

with Interfaces.C;
import Interfaces.C;

A Vibe module imports this unit's names with from Interfaces.C import Name; see library use across syntaxes. In Varc, keep each name's declared spelling and write & on arguments the call changes.

Contract and lifecycle reading

A Pre condition is the caller's obligation; a Post is what a normal return guarantees. What a postcondition does not state, a client cannot assume. Ghost functions are for contracts and ghost code. The family guide describes copying, lifetime, order and cost.

API 001

int (declaration) — The C type of the 64-bit (LP64) hosts Verada runs on, with the range, modulus or digits below.

Declared interface:

type int is range -2 ** 31 .. 2 ** 31 - 1;

API 002

short (declaration) — The C type of the 64-bit (LP64) hosts Verada runs on, with the range, modulus or digits below.

Declared interface:

type short is range -2 ** 15 .. 2 ** 15 - 1;

API 003

long (declaration) — The C type of the 64-bit (LP64) hosts Verada runs on, with the range, modulus or digits below.

Declared interface:

type long is range -2 ** 63 .. 2 ** 63 - 1;

API 004

signed_char (declaration) — The C type of the 64-bit (LP64) hosts Verada runs on, with the range, modulus or digits below.

Declared interface:

type signed_char is range -128 .. 127;

API 005

unsigned (declaration) — The C type of the 64-bit (LP64) hosts Verada runs on, with the range, modulus or digits below.

Declared interface:

type unsigned is mod 2 ** 32;

API 006

unsigned_short (declaration) — The C type of the 64-bit (LP64) hosts Verada runs on, with the range, modulus or digits below.

Declared interface:

type unsigned_short is mod 2 ** 16;

API 007

unsigned_long (declaration) — The C type of the 64-bit (LP64) hosts Verada runs on, with the range, modulus or digits below.

Declared interface:

type unsigned_long is mod 2 ** 64;

API 008

unsigned_char (declaration) — The C type of the 64-bit (LP64) hosts Verada runs on, with the range, modulus or digits below.

Declared interface:

type unsigned_char is mod 2 ** 8;

API 009

size_t (declaration) — The C type of the 64-bit (LP64) hosts Verada runs on, with the range, modulus or digits below.

Declared interface:

type size_t is mod 2 ** 64;

API 010

C_float (declaration) — The C type of the 64-bit (LP64) hosts Verada runs on, with the range, modulus or digits below.

Declared interface:

type C_float is digits 6;

API 011

double (declaration) — The C type of the 64-bit (LP64) hosts Verada runs on, with the range, modulus or digits below.

Declared interface:

type double is digits 15;

API 012

char (declaration) — LP64 C ABI character type derived from Character; conversions are explicit.

Declared interface:

type char is new Character;

API 013

nul (declaration) — C char position zero, the terminator used by default String/char_array conversions.

Declared interface:

nul : constant char := char'First;

API 014

To_C (declaration) — Convert Character/String into the supplied C character representation; String defaults to appending nul and must meet its length guard.

API 015

To_Ada (declaration) — Convert C character data to Character/String; trimming a char_array requires a terminating nul.

API 016

char_array (declaration) — LP64 C ABI character array indexed by size_t. Foreign calls receive a component pointer without an implicit length; preserve valid storage/lifetime.

Declared interface:

type char_array is array (size_t range <>) of char;

API 017

To_C (declaration) — Convert Character/String into the supplied C character representation; String defaults to appending nul and must meet its length guard.

Before this operation, establish:

Append_Nul or Item'Length > 0

On normal return the declared contract establishes:

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)

API 018

To_Ada (declaration) — Convert C character data to Character/String; trimming a char_array requires a terminating nul.

Before this operation, establish:

(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))