From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 2002:a02:8c78:: with SMTP id j53-v6mr599563jal.49.1530703402799; Wed, 04 Jul 2018 04:23:22 -0700 (PDT) X-Received: by 2002:aca:2b06:: with SMTP id i6-v6mr354780oik.0.1530703402596; Wed, 04 Jul 2018 04:23:22 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!feeder4.usenet.farm!feed.usenet.farm!weretis.net!feeder6.news.weretis.net!feeder.usenetexpress.com!feeder-in1.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!d7-v6no1593619itj.0!news-out.google.com!z3-v6ni1749iti.0!nntp.google.com!u78-v6no1593465itb.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Wed, 4 Jul 2018 04:23:22 -0700 (PDT) In-Reply-To: <3199b658-cc7d-47be-bc4d-a8346c0d765a@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=2a02:c7d:3c35:b000:325a:3aff:fe0f:37a5; posting-account=L2-UcQkAAAAfd_BqbeNHs3XeM0jTXloS NNTP-Posting-Host: 2a02:c7d:3c35:b000:325a:3aff:fe0f:37a5 References: <85743ee2-7d33-4024-a497-73a8dae0f480@googlegroups.com> <3199b658-cc7d-47be-bc4d-a8346c0d765a@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <6294202b-73d0-4c8c-af6f-e3435b4432c3@googlegroups.com> Subject: Re: Interface Ada string with C++ std::string From: Lucretia Injection-Date: Wed, 04 Jul 2018 11:23:22 +0000 Content-Type: text/plain; charset="UTF-8" Xref: reader02.eternal-september.org comp.lang.ada:53572 Date: 2018-07-04T04:23:22-07:00 List-Id: On Wednesday, 4 July 2018 04:33:59 UTC+1, Roger wrote: > On Wednesday, July 4, 2018 at 2:56:15 AM UTC+10, Lucretia wrote: > > On Tuesday, 3 July 2018 13:59:56 UTC+1, Roger wrote: > > > I am need to interface an Ada procedure to a C++ function that takes a std::string as an input parameter. > > > Can someone advise me how to do this? > > > > See https://github.com/Lucretia/test_binding > > Thanks for this, it looks promising. > I have cloned test_binding, built and run it and am now using it as a basis for my own situation. 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;