* Interfacing with C++
@ 2001-06-21 20:28 Hagi Yilmaz
2001-06-21 20:44 ` Ted Dennison
0 siblings, 1 reply; 5+ messages in thread
From: Hagi Yilmaz @ 2001-06-21 20:28 UTC (permalink / raw)
To: comp.lang.ada
Hello,
I have a little problem in Mapping C++, char * to Ada 95
c.strings_chars_ptr.
in C++ code :
"
....
extern "C" {void ada_call (char *x) }; // ada function I call.
. . .
char *x;
x=(char *) malloc(100);
ada_call(x);
MessageBox(x);
. . .
"
in ada code :
"
procedure ada_call(x : in out c.strings_chars_ptr) is
begin
x:=New_String(Str => "xxx"); -- x changes...
end ada_call;
. . .
"
My problem : In C code I write the output by "MessageBox" but see incorrect
characters are returning from Ada.
How should I build the Interface?
When there is a c.strings_chars_ptr with "in out" parameter,
how can I get correct returnings from ada in such a case?
How should be the Ada and C codes?
Can anybody help me for that? ...
Hagi Yilmaz
hagihun@hotmail.com
_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Interfacing with C++
2001-06-21 20:28 Hagi Yilmaz
@ 2001-06-21 20:44 ` Ted Dennison
0 siblings, 0 replies; 5+ messages in thread
From: Ted Dennison @ 2001-06-21 20:44 UTC (permalink / raw)
In article <mailman.993155362.16396.comp.lang.ada@ada.eu.org>, Hagi Yilmaz
says...
>I have a little problem in Mapping C++, char * to Ada 95
>c.strings_chars_ptr.
>
>extern "C" {void ada_call (char *x) }; // ada function I call.
>in ada code :
> procedure ada_call(x : in out c.strings_chars_ptr) is
That's wrong. Read your Ada references (prefereably the LRM) a bit more
carefully. What you are saying with "in out c.strings_chars_ptr" is that the
program is allowed to update the value of the pointer. In order to do that in C,
you'd need a "char **" parameter.
You are going to need to either change the C side to "char **", or the Ada side
to something like C.Chars_Array or mode "in", depending on what you really want
to do with the parameter.
---
T.E.D. homepage - http://www.telepath.com/dennison/Ted/TED.html
home email - mailto:dennison@telepath.com
^ permalink raw reply [flat|nested] 5+ messages in thread
* Interfacing with C++
@ 2001-10-10 20:01 Hagi Yilmaz
2001-10-11 11:06 ` Peter Hend�n
0 siblings, 1 reply; 5+ messages in thread
From: Hagi Yilmaz @ 2001-10-10 20:01 UTC (permalink / raw)
To: comp.lang.ada
Hello,
How Can I map the "CString" in VC++ to Ada 95?
Can I pass the "CString" from VC++ as parameter to an Ada procedure or
function.
In fact I Use at the moment the (char *) for Interface, but I have to
allocate it from VC++ or from Ada 95 (chars_ptr) .And of course de-allocate
it, not to cause a storage leak.
But i thougt if i could use "CString" somehow, i would not have to deal
with memory leaks anymore.
Can anybody help me for that? ...
Best Regards.
Hagi Yilmaz
hagihun@hotmail.com
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Interfacing with C++
2001-10-10 20:01 Interfacing with C++ Hagi Yilmaz
@ 2001-10-11 11:06 ` Peter Hend�n
0 siblings, 0 replies; 5+ messages in thread
From: Peter Hend�n @ 2001-10-11 11:06 UTC (permalink / raw)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1032 bytes --]
If you're using GNAT you might check out "Interfacing to C++" in
the reference manual.
/Peter H.
--
Peter Hend�n http://www.algonet.se/~phenden
ICQ: 14672398
Teknisk Dokumentation AB http://www.tdab.com
"Hagi Yilmaz" <hagihun@hotmail.com> wrote in message
news:mailman.1002744075.16878.comp.lang.ada@ada.eu.org...
> Hello,
>
> How Can I map the "CString" in VC++ to Ada 95?
>
> Can I pass the "CString" from VC++ as parameter to an Ada procedure or
> function.
>
> In fact I Use at the moment the (char *) for Interface, but I have to
> allocate it from VC++ or from Ada 95 (chars_ptr) .And of course
de-allocate
> it, not to cause a storage leak.
>
> But i thougt if i could use "CString" somehow, i would not have to deal
> with memory leaks anymore.
>
> Can anybody help me for that? ...
>
> Best Regards.
>
> Hagi Yilmaz
> hagihun@hotmail.com
>
>
>
>
> _________________________________________________________________
> Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Interfacing with C++
[not found] <F2728u4xIt1YtxQEfQm00001bff@hotmail.com>
@ 2001-10-11 11:37 ` David Botton
0 siblings, 0 replies; 5+ messages in thread
From: David Botton @ 2001-10-11 11:37 UTC (permalink / raw)
To: comp.lang.ada
The following works:
procedure MyString (C_String : in Interfaces.C.Char_Array) is etc.
From C/C++
CString theStr;
MyString ((LPCSTR) theStr);
What exactly are you looking to do?
David Botton
----- Original Message -----
From: "Hagi Yilmaz" <hagihun@hotmail.com>
To: <comp.lang.ada@ada.eu.org>
Sent: Wednesday, October 10, 2001 4:01 PM
Subject: Interfacing with C++
> Hello,
>
> How Can I map the "CString" in VC++ to Ada 95?
>
> Can I pass the "CString" from VC++ as parameter to an Ada procedure or
> function.
>
> In fact I Use at the moment the (char *) for Interface, but I have to
> allocate it from VC++ or from Ada 95 (chars_ptr) .And of course
de-allocate
> it, not to cause a storage leak.
>
> But i thougt if i could use "CString" somehow, i would not have to deal
> with memory leaks anymore.
>
> Can anybody help me for that? ...
>
> Best Regards.
>
> Hagi Yilmaz
> hagihun@hotmail.com
>
>
>
>
> _________________________________________________________________
> Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp
>
> _______________________________________________
> comp.lang.ada mailing list
> comp.lang.ada@ada.eu.org
> http://ada.eu.org/mailman/listinfo/comp.lang.ada
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2001-10-11 11:37 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-10-10 20:01 Interfacing with C++ Hagi Yilmaz
2001-10-11 11:06 ` Peter Hend�n
[not found] <F2728u4xIt1YtxQEfQm00001bff@hotmail.com>
2001-10-11 11:37 ` David Botton
-- strict thread matches above, loose matches on Subject: below --
2001-06-21 20:28 Hagi Yilmaz
2001-06-21 20:44 ` Ted Dennison
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox