Reputation: 75
I have seen numerous places that communication between Ada/C/C++ is possible using export/import keywords. What about if the Ada function is a generic; is this even possible?
My problem is that I need to reuse some legacy code and we have numerous generic Ada functions. The new layer coming will be written in C++ and I am hoping to be able to export these existing Ada generic functions to a C++ wrapper. (Actually, if the functions aren't global I will need another layer but nevermind that right now.)
If it is NOT possible I will just need to create new individual Ada functions specific to the different types which in turn call the generic. Any thoughts about this approach?
I am definitely a noob with Ada programming so excuse my ignorance. Thanks for the help.
Upvotes: 4
Views: 741
Reputation: 11730
I'm not familiar w/ Ada, but you should be able to call exported functions (assuming the Ada compiler does nothing too perverse). You should try dumping the Ada object file (the result of compilation) to inspect the function names.
Upvotes: -2
Reputation: 205785
Write a small Ada package whose specification contains the exported subprograms and whose body instantiates those subprograms using the types available in §B.3 Interfacing with C and C++. Don't neglect to call adainit()
and adafinal()
on the C side. More here.
Upvotes: 3