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 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,51114679936bf41a X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local01.nntp.dca.giganews.com!nntp.comcast.com!news.comcast.com.POSTED!not-for-mail NNTP-Posting-Date: Sun, 14 May 2006 08:52:51 -0500 Date: Sun, 14 May 2006 09:39:22 -0400 From: Jeffrey Creem User-Agent: Mozilla Thunderbird 1.0.7 (Windows/20050923) X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Calling C++ from Ada References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: NNTP-Posting-Host: 24.147.74.171 X-Trace: sv3-UNPGB1eCY9eDfYICELi/WetQIK7FJiH9gx5rN6ckk1Eahr8LKUgKytt9PWNQJiKIARq4CHgOlB9ACGv!ntR01LC5rGV7A+HtDhd36sReqRr1KP24gz2TglUYIv8cfrHmEmfjuRDNXtBSIkXp2Pqp9IyEYWDi!Fog= X-Complaints-To: abuse@comcast.net X-DMCA-Complaints-To: dmca@comcast.net X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.32 Xref: g2news2.google.com comp.lang.ada:4247 Date: 2006-05-14T09:39:22-04:00 List-Id: Yves Bailly wrote: > On Sat, 13 May 2006 15:55:38 -0400, Jeffrey Creem wrote: > >>If you are thinking of doing something yourself perhaps you should look >>at adding an Ada output module for SWIG. >>Looking at some of the other language output modules it appears that it >>is a reasonably small project. > > > Interesting. I'll dig into this, it seems promising. > > Sorry if I'm boring everyone here, but I would like to submit some > thoughts on a way to call C++ from Ada, through a C wrapper, avoiding > too much dynamic memory allocations. I would not worry about boring anyone. This has been an area where there has always been interest since the early days of comp.lang.ada. I think most here are interested in the topic. > > The basic idea is to reserve the needed space on the Ada side, then to > use the placement "new" on the C++ side. > The biggest problem I see with th is is ithat it is not clear that this really is portable. The problem is that the code is making assumptions about the layout of the std::string class and assumptions about what the compiler will do with respect to dope vectors. While nesting the string in the record probably makes it so that the compiler does not need to generate a dope vector, I am not sure if it requires that the compiler not do so. I suspect there are also other issues with respect to the class, tags, and other layout issues that are not guaranteed to be portable. Having said that, it is worth pointing out that more "useful" implementations have been sacrificed on the alter of future portability in this newsgroup than I'd like to count. I hate to think of the number of approaches that were rejected due to portability and then replaced with something equally non-portable from a different language.