Ada call from C ++ in Eclipse

I am trying to create a program that is fully hosted in Eclipse, runs in C ++ and calls Ada. I download GNATBench and run Ada programs without any problems. What I cannot do is a C ++ project project for an Ada project.

After the hunt, I found and executed the code shown below using the make file.

http://www.pegasoft.ca/resources/boblap/book.html

I also found a message stating that my goal was accomplished.

http://blogs.windriver.com/parkinson/2009/10/yesterday-adacore-announced-the-release-of-gnatbench-231-its-ada-integrated-development-environment-eclipse-plugin-which.html

What else do I need to enable for C ++ in Eclipse to call Ada in Eclipse?


USING A SHOOT FILE:

$ c++ -c test.cc
$ gnatgcc -c test_subr
$ gnatbind -n test_subr
$ gnatgcc -c b~test_subr
$ gnatlink -o main test.o test_subr.ali --link=c++
$ ./main

CPP Code:

//main.cc

#include extern "C" void adainit(void);    
#include extern "C" void adafinal(void);
#include extern "C" void ada_subroutine(void);

int main(int argc, char **argv)
{
   puts("C++ main");
   adainit();

   ada_subroutine();

   adafinal();
   puts("C++ done");

   return 0;
}

Ada Code:

package Test_Subr is
    procedure Ada_Subroutine;
    pragma export(CPP, Ada_Subroutine);
end Test_Subr;

with Ada.Text_IO;
use Ada.Text_IO;

package body Test_Subr is

    procedure Ada_Subroutine is
    begin
        put("IN ADA");
    end Ada_Subroutine;

end Test_Subr;
+2
source share
3

External_Name Export pragma? ( IIRC, ++ .)

pragma Export
( Convention    => CPP,
  Entity        => Ada_Subroutine,
  External_Name => "Ada_Subroutine "
);
+3

Eclipse; , ++ Eclipse, ++? C?

, Eclipse Ada ++?

+2

extern C ++ pragma exprort (C, .. Ada, ( ) . , gcc Ada ++, pragma export (CPP.

There is another issue you should be aware of. If your "main" (entry point to the program) is not written in Ada , you will need to manually call the Ada development process (through a routine adainit()) before invoking anything. Likewise, you should in most cases call adafinal()before exiting your program.

+1
source

All Articles