Next: Interfacing to C++, Up: Interfacing to Other Languages
Interfacing to C with GNAT can use one of two approaches:
Interfaces.C may be used.
Pragma Convention C may be 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.
Integerint
Short_Integershort
Short_Short_Integersigned char
Long_Integerlong
Long_Long_Integerlong long
Short_Floatfloat
Floatfloat
Long_Floatdouble
Long_Long_FloatAdditionally, there are the following general correspondences between Ada and C types:
Convention C is specified, which causes them to have int
length. Without pragma Convention C, Ada enumeration types map to
8, 16, or 32 bits (i.e. C types signed char, short,
int, respectively) depending on the number of values passed.
This is the only case in which pragma Convention C affects the
representation of an Ada type.
'Size value in Ada.