Node: Interfacing to C, Next: , Up: Interfacing to Other Languages



Interfacing to C

Interfacing to C with GNAT can use one of two approaches:

  1. The types in the package Interfaces.C may be used.
  2. Standard Ada types may be used directly. This may be less portable to other compilers, but will work on all GNAT compilers, which guarantee correspondence between the C and Ada types.

Pragma Convention C maybe applied to Ada types, but mostly has no effect, since this is the default. The following table shows the correspondence between Ada scalar types and the corresponding C types.

Integer
int
Short_Integer
short
Short_Short_Integer
signed char
Long_Integer
long
Long_Long_Integer
long long
Short_Float
float
Float
float
Long_Float
double
Long_Long_Float
This is the longest floating-point type supported by the hardware.