While trying to make an ADA binding to a third party C/C++ library (SAPNWRFCSDK) I came to problems of type inference for array types:
First problem:
The Gnat-Binding-Generator from gcc (gcc -fdump-ada-spec) is generating lots of intermediate named array types for different index ranges:
type anon3115_anon3128_array is array (0 .. 8) of aliased SAP_UC;
type anon3115_anon3131_array is array (0 .. 3) of aliased SAP_UC;
type anon3115_anon3134_array is array (0 .. 12) of aliased SAP_UC;
Those types are used in records. If I want to pass those fields to a procedure or function I would like to have a unbounded type signature for example with following type:
type SAP_UC_Array is array (Int range <>) of aliased SAP_UC;
But the generated types are no subtypes of this cannot be passed. One solution would be to change the field declarations in the Records to:
field : SAP_UC_Array(0 .. 8);
But this would mean to "process" the generated binding file and change all definitions. Is it possible to create an named array subtype with a specified index range or what would be the solution?
Second Problem:
Some array type definitions have equivalent Component types.
subtype RFC_CHAR is SAP_UC;
type RFC_DATE is array (0 .. 7) of aliased RFC_CHAR;
This array definition is not considered as equivalent to an Array of Component type SAP_UC. Is it possible to tell Ada that these types are equivalent?