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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: Luke A. Guest Newsgroups: comp.lang.ada Subject: Re: Ada and C++ in the same binary, was: Re: Current status of Ada development for an Android target ? Date: Sat, 18 Jun 2016 19:21:51 +0100 Organization: Aioe.org NNTP Server Message-ID: <1277310445.487966038.242735.laguest-archeia.com@nntp.aioe.org> References: <623218455.487799273.877639.laguest-archeia.com@nntp.aioe.org> NNTP-Posting-Host: sa8AiQCBDKs7tRLBVKdeIg.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Complaints-To: abuse@aioe.org User-Agent: NewsTap/5.1.8 (iPhone/iPod Touch) Cancel-Lock: sha1:TngpNrMOivyoyTRV+BtO3HYKA8U= X-Notice: Filtered by postfilter v. 0.8.2 Xref: news.eternal-september.org comp.lang.ada:30793 Date: 2016-06-18T19:21:51+01:00 List-Id: Simon Clubley wrote: > Thanks Luke, but please don't go to any special effort on my behalf. I had a go with google's compiler source on armv7-a, doesn't build. I have an inkling that they've broken the Ada build machinery stuff on purpose. > Having thought about the situation, I'm getting nervous once again about > the "special" :-( situation around Ada compilers given that I'm not > sure where some of this code might be used in the future. It is a pain. > > My current thinking (as of this morning :-)) is to maybe write the low > level stuff in C++ (which is the code more likely to be used elsewhere) > and to do the high level stuff in Ada. You'll still require a compiler that can build it. > The problem is that I don't have any experience combining C++ and Ada > code in the same binary; in the past, I've only ever called plain C code > from Ada. Depends how you do it. It's tricky. You could use g++ as a generator but you need to massage it by hand to get it to work. You could wrap the classes by hand and flatten the API out to a bunch of C functions. You could then wrap that API in Ada tagged types, which has its own issues of you need to get an Ada tagged type back from the C++ side. As an example, when I was attempting to wrap wxWidgets you can create a wxFrame with a menu and status bar without needing to define Ada types for them. So when you want to grab a status bar from the frame, you have to wrap the C++ pointer to the class you get back from the call in C with an Ada tagged type that knows not to delete it on finalisation. The handling of these things is the main issue with using proxy types. Using the generator will be easier and faster but less portable to any other future compilers, if any. > Does anyone know of any issues combining C++ and Ada code in the same > binary when using gcc and binutils ? Are there any conflicts with > exceptions for example ? The original non-working code for wxAda is on Tigris. > The primary use of such binaries would be on a Linux x86 (and maybe > ARM) platform.