From: Roger <rogermcm2@gmail.com>
Subject: Re: Interface Ada string with C++ std::string
Date: Wed, 4 Jul 2018 04:45:28 -0700 (PDT)
Date: 2018-07-04T04:45:28-07:00 [thread overview]
Message-ID: <4b11d923-8412-48bc-9406-d3aaaa81e6f2@googlegroups.com> (raw)
In-Reply-To: <6294202b-73d0-4c8c-af6f-e3435b4432c3@googlegroups.com>
On Wednesday, July 4, 2018 at 9:23:23 PM UTC+10, Lucretia wrote:
> All you probably need is a C function which returns the string c_str() to Ada which Ada can then use, wrap that in Ada. Just define a private type for the string class which is an address and pass that to the C function.
>
> package CPP_Strings is
> type CPP_String is private;
>
> function Get (S : in CPP_String) return String; -- Wrap the C->Ada stuff inside here.
> private
> type CPP_String is System.Address;
> end CPP_Strings;
Thanks,
I was playing around today modifying your test_binding code then managed to accidentally delete everything I'd done!
I think I'll have another go at it as it is an educational experience.
Once I've done that, I'll be in a better position to understand and implement what you've just suggested.
Everything is pretty much in line with my thinking. My main problem is my minimal experience with C++ so your helping hand is very welcome.
Once I found it impossible to directly interface std::string to Ada, I thought the way ahead would be to write a C interface to C++ and then wrap the C interface to Ada as you have suggested.
My original post was due to not being sure how to do it. So your advice has been a tremendous help and makes me confident that I'll get there eventually.
next prev parent reply other threads:[~2018-07-04 11:45 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-03 12:59 Interface Ada string with C++ std::string Roger
2018-07-03 13:13 ` Dan'l Miller
2018-07-03 13:16 ` Roger
2018-07-03 16:34 ` Jacob Sparre Andersen
2018-07-03 16:52 ` Roger
2018-07-03 16:56 ` Lucretia
2018-07-04 3:33 ` Roger
2018-07-04 4:13 ` Roger
2018-07-04 11:23 ` Lucretia
2018-07-04 11:45 ` Roger [this message]
2018-07-04 11:52 ` Lucretia
2018-07-05 1:08 ` Roger
2018-07-05 23:32 ` Roger
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox