Node:Restrictions on foreign declarations, Next:Linking with foreign object files, Previous:Interfacing to other languages, Up:Interfacing to other languages
Any subprogram can be imported. GHDL puts no restrictions on foreign subprograms. However, the representation of a type or of an interface in a foreign language may be obscur. Most of non-composite types are easily imported:
integer types
int
for C
or Integer
for Ada
.physical types
long long
for C
or Long_Long_Integer
for Ada
.floating point types
double
for C
or Long_Float
for Ada
.enumeration types
Non-composite types are passed by value. For the in
mode, this corresponds to the C
or Ada
mechanism. The out
and inout
interfaces of non-composite types are gathered in a record and this record is passed by reference as the first argument to the subprogram. As a consequence, you shouldn't use in
and inout
modes in foreign subprograms, since they are not portable.
Records are represented like a C
structure and are passed by reference to subprograms.
Arrays with static bounds are represented like a C
array, whose length is the number of elements, and are passed by reference to subprograms.
Unconstrained array are represented by a fat pointer. Do not use unconstrained arrays in foreign subprograms.
Accesses to an unconstrained array is a fat pointer. Other accesses corresponds a an address and are passed to a subprogram like other non-composite types.
Files are represented by a 32 bits word, which corresponds to an index in a table.