Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you export Ada generic functions to C++?

Tags:

c++

c

ada

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.

like image 351
JSolberg Avatar asked Nov 04 '22 01:11

JSolberg


1 Answers

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.

like image 165
trashgod Avatar answered Nov 09 '22 04:11

trashgod