Hello world!
Copy and paste the following code and then try to execute it.
world.cpp:
#include <stdio.h>
#include <iostream>
extern "C" void cfunc() {
printf(" C: Hi Ada!\n");
}
extern "C" void cppfunc() {
std::cout << "C++: Hi Ada!\n";
}
hello.adb
with Ada.Text_Io; use Ada.Text_Io;
procedure Poc is
procedure CFunc;
pragma Import(C,cfunc);
procedure CPPFunc;
pragma Import(C,cppfunc);
begin
Put_Line("Ada: Hi C!");
CFunc;
Put_Line("Ada: Hi C++!");
CPPFunc;
Put_Line("Ada: We cooperate!");
end Poc;
I achieve to run it with the following commands (having gcc 3.2 with C, C++ and Ada 95 enabled):
gnatmake hello -c
gnatbind hello -C
gnatlink hello world.o -C --LINK=g++
Run the program - just being able to link it doesn't mean everything is fine!
Comments are welcome.
Requirements
Hello world!
Download
e-Mail: denny@nodix.de
|