I need to pass 2 pieces of data from an Ada program to some C++ code for processing.
- Data - double.
- Time - unsigned 64 bits.
I was able to make a procedure in Ada that worked with my C++ method using a Long_Float (double in C++) and Integer (int in C++, obviously not 64-bits though). I used the following code (code not on me so syntax might be slightly off):
procedure send_data (this : in hidden_ptr; data : in Long_Float; time : in Integer);
pragma import (CPP, send_data, "MyClass::sendData");
Now that that's working, I'm trying to expand the time to the full 64-bits and ideally would like to have an unsigned long long on the C++ side. I don't see any types in Ada that match that so I created my own type:
type U64 is mod 2 ** 64;
When using that type with my send_data method I get an error saying there are no possible ways to map that type to a C++ type (something along those lines, again don't have the code or exact error phrase on me).
Is there a way to pass a user-defined type in Ada to C++? Perhaps there's another type in Ada I can use as an unsigned 64-bit value that would work? Is there a way to pass the address of my U64 type as a parameter to the C++ method instead if that's easier? I'm using the green hills adamulti compiler v3.5 (very new to ada, not sure if that info helps or not). Examples would be greatly appreciated!
mod 2 ** 64should be correct. When I compile your example using that type with GNAT, it doesn't complain. Perhaps your Ada compiler doesn't think that C++ (or the C++ compiler it targets) supports a 64-bit unsigned type; standard C++ didn't getunsigned long longuntil the 2011 ISO standard.pragma Convention (CPP, U64);.unsigned long long, which could have different sizes in different implementations, trystd::uint64_t.