* Calling C++ methods from Ada..
@ 2004-12-01 21:11 Ganesh Ramasivan
2004-12-01 23:05 ` Luke A. Guest
2004-12-02 4:36 ` Brian May
0 siblings, 2 replies; 14+ messages in thread
From: Ganesh Ramasivan @ 2004-12-01 21:11 UTC (permalink / raw)
The following is a small test program in which the Ada function is
implemented in C++.
------------------------------
with System;
procedure CppTest is
procedure SET_TIME (hour: System.Address);
pragma import(CPP, SET_TIME, "Time::SetTime");
begin
null;
end CppTest;
--------------------------------
I get the following error when I compile this code using the GHS Ada
compiler under Solaris 2.8. Can anybody please tell me what I am doing
wrong?
c8966@gatekeeper: cpp>build CppTest.bld
Compiling /home/c8966/ada/cpp/CppTest.ada because "CppTest.o" doesn't
exist
/home/c8966/ada/cpp/CppTest.ada: Error: line 83 col 10 LRM:B.1(26), No
compatible C++ type for System.Address_Target
Error: build failed
Build terminated
Thanks,
Ganesh
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Calling C++ methods from Ada..
2004-12-01 21:11 Calling C++ methods from Ada Ganesh Ramasivan
@ 2004-12-01 23:05 ` Luke A. Guest
2004-12-02 0:21 ` Jeff C r e e.m
2004-12-02 11:12 ` Brian May
2004-12-02 4:36 ` Brian May
1 sibling, 2 replies; 14+ messages in thread
From: Luke A. Guest @ 2004-12-01 23:05 UTC (permalink / raw)
What compiler are you using?
Luke.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Calling C++ methods from Ada..
2004-12-01 23:05 ` Luke A. Guest
@ 2004-12-02 0:21 ` Jeff C r e e.m
2004-12-02 11:12 ` Brian May
1 sibling, 0 replies; 14+ messages in thread
From: Jeff C r e e.m @ 2004-12-02 0:21 UTC (permalink / raw)
"Luke A. Guest" <laguest@n_o_p_o_r_k_a_n_d_h_a_m.abyss2.demon.co.uk> wrote
in message
news:pan.2004.12.01.23.05.04.344825@n_o_p_o_r_k_a_n_d_h_a_m.abyss2.demon.co.uk...
> What compiler are you using?
>
> Luke.
>
It was not obvious but he said GHS (Green Hills) in the original message.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Calling C++ methods from Ada..
2004-12-01 21:11 Calling C++ methods from Ada Ganesh Ramasivan
2004-12-01 23:05 ` Luke A. Guest
@ 2004-12-02 4:36 ` Brian May
1 sibling, 0 replies; 14+ messages in thread
From: Brian May @ 2004-12-02 4:36 UTC (permalink / raw)
>>>>> "Ganesh" == Ganesh Ramasivan <ganesh.ramasivan@gdcanada.com> writes:
Ganesh> procedure CppTest is
Ganesh> procedure SET_TIME (hour: System.Address); pragma
Ganesh> import(CPP, SET_TIME, "Time::SetTime");
Ganesh> begin null; end CppTest;
Is Time::SetTime a static member function? You didn't give the
definition in your E-Mail so I can't tell..
If it isn't, then it is a class method, and requires a hidden *this
parameter.
Furthermore, if it is a virtual function, then a static binding may
not be appropriate.
Check the GNAT reference manual for details on the following pragmas
(section 10.2 Interfacing to C++):
pragma CPP_Class
pragma CPP_Constructor
pragma CPP_Vtable
Note I haven't used any of these, don't understand (yet) how to use
them, and I don't know of any examples (do a web search).
--
Brian May <bam@snoopy.apana.org.au>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Calling C++ methods from Ada..
2004-12-01 23:05 ` Luke A. Guest
2004-12-02 0:21 ` Jeff C r e e.m
@ 2004-12-02 11:12 ` Brian May
2004-12-02 21:32 ` Luke A. Guest
1 sibling, 1 reply; 14+ messages in thread
From: Brian May @ 2004-12-02 11:12 UTC (permalink / raw)
>>>>> "Luke" == Luke A Guest <laguest@n_o_p_o_r_k_a_n_d_h_a_m.abyss2.demon.co.uk> writes:
Luke> What compiler are you using?
Good point - I assumed he was using GNAT, so the solution I gave may
not be relevant if he is not using GNAT. I am not sure if the pragmas
I gave are GNAT specific or not.
--
Brian May <bam@snoopy.apana.org.au>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Calling C++ methods from Ada..
2004-12-02 11:12 ` Brian May
@ 2004-12-02 21:32 ` Luke A. Guest
2004-12-02 21:49 ` Adrien Plisson
2004-12-03 8:59 ` Martin Krischik
0 siblings, 2 replies; 14+ messages in thread
From: Luke A. Guest @ 2004-12-02 21:32 UTC (permalink / raw)
On Thu, 02 Dec 2004 22:12:03 +1100, Brian May wrote:
>>>>>> "Luke" == Luke A Guest <laguest@n_o_p_o_r_k_a_n_d_h_a_m.abyss2.demon.co.uk> writes:
>
> Luke> What compiler are you using?
>
> Good point - I assumed he was using GNAT, so the solution I gave may
> not be relevant if he is not using GNAT. I am not sure if the pragmas
> I gave are GNAT specific or not.
Yeah, I didn't see the reference to GHS, I must've just skimmed past ;-),
but the code he posted wouldn't work on GNAT anyway because you have to
provide GNAT the mangled C++ names, which is crap IMO.
Luke.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Calling C++ methods from Ada..
2004-12-02 21:32 ` Luke A. Guest
@ 2004-12-02 21:49 ` Adrien Plisson
2004-12-03 8:59 ` Martin Krischik
1 sibling, 0 replies; 14+ messages in thread
From: Adrien Plisson @ 2004-12-02 21:49 UTC (permalink / raw)
Luke A. Guest wrote:
> but the code he posted wouldn't work on GNAT anyway because you have to
> provide GNAT the mangled C++ names, which is crap IMO.
and compiler dependent... and even rarely documented...
--
rien
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Calling C++ methods from Ada..
2004-12-02 21:32 ` Luke A. Guest
2004-12-02 21:49 ` Adrien Plisson
@ 2004-12-03 8:59 ` Martin Krischik
2004-12-03 13:55 ` Luke A. Guest
` (2 more replies)
1 sibling, 3 replies; 14+ messages in thread
From: Martin Krischik @ 2004-12-03 8:59 UTC (permalink / raw)
Luke A. Guest wrote:
> On Thu, 02 Dec 2004 22:12:03 +1100, Brian May wrote:
>
>>>>>>> "Luke" == Luke A Guest
>>>>>>> <laguest@n_o_p_o_r_k_a_n_d_h_a_m.abyss2.demon.co.uk> writes:
>>
>> Luke> What compiler are you using?
>>
>> Good point - I assumed he was using GNAT, so the solution I gave may
>> not be relevant if he is not using GNAT. I am not sure if the pragmas
>> I gave are GNAT specific or not.
>
> Yeah, I didn't see the reference to GHS, I must've just skimmed past ;-),
> but the code he posted wouldn't work on GNAT anyway because you have to
> provide GNAT the mangled C++ names, which is crap IMO.
The original idea was a C++ parser which generated the bindings. With the
complexity of C++ the only way to go. However the parser never
happend :-( .
Martin
--
mailto://krischik@users.sourceforge.net
http://www.ada.krischik.com
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Calling C++ methods from Ada..
2004-12-03 8:59 ` Martin Krischik
@ 2004-12-03 13:55 ` Luke A. Guest
2004-12-03 13:58 ` Luke A. Guest
2004-12-03 14:06 ` Luke A. Guest
2 siblings, 0 replies; 14+ messages in thread
From: Luke A. Guest @ 2004-12-03 13:55 UTC (permalink / raw)
On Fri, 03 Dec 2004 09:59:22 +0100, Martin Krischik wrote:
> The original idea was a C++ parser which generated the bindings. With the
> complexity of C++ the only way to go. However the parser never
> happend :-( .
That's just overkill, the way to do it is like the example the OP posted.
Have the compiler take a pragma which determines which C++ compiler the
binding is from, this determines the name mangling method (as they're all
different), then when the Ada compiler comes across an import of a C++
method (with class scoping), it can generate the correct bindings.
Luke.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Calling C++ methods from Ada..
2004-12-03 8:59 ` Martin Krischik
2004-12-03 13:55 ` Luke A. Guest
@ 2004-12-03 13:58 ` Luke A. Guest
2004-12-04 10:09 ` Brian May
2004-12-03 14:06 ` Luke A. Guest
2 siblings, 1 reply; 14+ messages in thread
From: Luke A. Guest @ 2004-12-03 13:58 UTC (permalink / raw)
So, the example could be written like this:
pragma import(CPP, GCC3, SET_TIME, "void Time::SetTime(...)");
Although, I'm not sure why he would be passing in a pointer to a set time
function ;-)
Luke.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Calling C++ methods from Ada..
2004-12-03 8:59 ` Martin Krischik
2004-12-03 13:55 ` Luke A. Guest
2004-12-03 13:58 ` Luke A. Guest
@ 2004-12-03 14:06 ` Luke A. Guest
2004-12-04 13:22 ` Georg Bauhaus
2 siblings, 1 reply; 14+ messages in thread
From: Luke A. Guest @ 2004-12-03 14:06 UTC (permalink / raw)
On Fri, 03 Dec 2004 09:59:22 +0100, Martin Krischik wrote:
> The original idea was a C++ parser which generated the bindings. With the
> complexity of C++ the only way to go. However the parser never
> happend :-( .
I wonder how much work it would be to add a switch to the GCC C++ compiler
to enable generation of GNAT bindings (when --languages has ada passed on
the configuration command line)?
Luke.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Calling C++ methods from Ada..
2004-12-03 13:58 ` Luke A. Guest
@ 2004-12-04 10:09 ` Brian May
0 siblings, 0 replies; 14+ messages in thread
From: Brian May @ 2004-12-04 10:09 UTC (permalink / raw)
>>>>> "Luke" == Luke A Guest <laguest@n_o_p_o_r_k_a_n_d_h_a_m.abyss2.demon.co.uk> writes:
Luke> So, the example could be written like this: pragma
Luke> import(CPP, GCC3, SET_TIME, "void Time::SetTime(...)");
Luke> Although, I'm not sure why he would be passing in a pointer
Luke> to a set time function ;-)
Of course you need at least one pointer - don't forget the hidden C++
*this parameter...
(I am still assuming the function in question is static).
--
Brian May <bam@snoopy.apana.org.au>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Calling C++ methods from Ada..
2004-12-03 14:06 ` Luke A. Guest
@ 2004-12-04 13:22 ` Georg Bauhaus
2004-12-05 1:51 ` David Botton
0 siblings, 1 reply; 14+ messages in thread
From: Georg Bauhaus @ 2004-12-04 13:22 UTC (permalink / raw)
Luke A. Guest <laguest@n_o_p_o_r_k_a_n_d_h_a_m.abyss2.demon.co.uk> wrote:
: On Fri, 03 Dec 2004 09:59:22 +0100, Martin Krischik wrote:
:
:> The original idea was a C++ parser which generated the bindings. With the
:> complexity of C++ the only way to go. However the parser never
:> happend :-( .
:
: I wonder how much work it would be to add a switch to the GCC C++ compiler
: to enable generation of GNAT bindings (when --languages has ada passed on
: the configuration command line)?
Maybe there are some traces of this idea in GCC/GNAT for .NET/.GNU/.WHATEVER?
(I'm guessing this because much in .NET is about extensible types with
operations as part of a common language infrasructure. So if GCC is
enabled to build type information for MSIL (?), the information needed to
generate Ada bindings should be right there.)
-- Georg
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Calling C++ methods from Ada..
2004-12-04 13:22 ` Georg Bauhaus
@ 2004-12-05 1:51 ` David Botton
0 siblings, 0 replies; 14+ messages in thread
From: David Botton @ 2004-12-05 1:51 UTC (permalink / raw)
See Martin Carlisles' A#. It's in there.
http://www.usafa.af.mil/dfcs/bios/mcc_html/a_sharp.html
David Botton
On 2004-12-04 08:22:07 -0500, Georg Bauhaus
<sb463ba@l1-hrz.uni-duisburg.de> said:
> Luke A. Guest <laguest@n_o_p_o_r_k_a_n_d_h_a_m.abyss2.demon.co.uk> wrote:
> : On Fri, 03 Dec 2004 09:59:22 +0100, Martin Krischik wrote:
> : :> The original idea was a C++ parser which generated the bindings. With the
> :> complexity of C++ the only way to go. However the parser never
> :> happend :-( .
> : : I wonder how much work it would be to add a switch to the GCC C++ compiler
> : to enable generation of GNAT bindings (when --languages has ada passed on
> : the configuration command line)?
>
> Maybe there are some traces of this idea in GCC/GNAT for .NET/.GNU/.WHATEVER?
> (I'm guessing this because much in .NET is about extensible types with
> operations as part of a common language infrasructure. So if GCC is
> enabled to build type information for MSIL (?), the information needed to
> generate Ada bindings should be right there.)
>
>
> -- Georg
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2004-12-05 1:51 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-12-01 21:11 Calling C++ methods from Ada Ganesh Ramasivan
2004-12-01 23:05 ` Luke A. Guest
2004-12-02 0:21 ` Jeff C r e e.m
2004-12-02 11:12 ` Brian May
2004-12-02 21:32 ` Luke A. Guest
2004-12-02 21:49 ` Adrien Plisson
2004-12-03 8:59 ` Martin Krischik
2004-12-03 13:55 ` Luke A. Guest
2004-12-03 13:58 ` Luke A. Guest
2004-12-04 10:09 ` Brian May
2004-12-03 14:06 ` Luke A. Guest
2004-12-04 13:22 ` Georg Bauhaus
2004-12-05 1:51 ` David Botton
2004-12-02 4:36 ` Brian May
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox