Can you name the C ++ functions from Ada?

Can you call C ++ functions from Ada?

I am wondering if there is a way to do this directly, without performing a C implementation and writing a C ++ wrapper and Ada shell, for example. I would like to go C ++ → Ada, not C ++ → c → Ada.

+3
source share
7 answers

The problem with Ada in C ++ is that C ++ does not have a specific ABI.
Each compiler is allowed to determine the most efficient ABI that it can.

, (Ada) - , Ada, , ++, / ++.

, C ABI , , .

+4

-, , , , ++ C .

C, ++ C ( Ada), . , , - ++, , extern ++.

++ extern "C", . ++ Ada Ada.

:

cpp:

extern "C" int cpp_func (int p1, int p2) {
   ; // Whatever..
}

.adb:

function cpp_func (p1, p2 : Interfaces.C.Int) return Interfaces.C.Int;
pragma Import (C, cpp_func); 

...
Result : constant Interfaces.C.Int := cpp_func (1, 2);
+4

...

" ++ Ada Ada ( 95)"

+1

Ada 99/00, , Ada, - ++ ( ) ++ dll (-), C DLL, pragma, c, DLL .

, , pragma C, dll ++.

It was mostly pain. I think we had to use the Win32 Lean directive and Mean precomplier in the C shell.

In any case, all three of us who worked on the project can remember.

+1
source

swig could do it

+1
source

Green Hills software has also published an excellent PDF file.
http://www.ghs.com/download/whitepapers/ada_c++.pdf

0
source

Source: https://habr.com/ru/post/1704212/


All Articles