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!feeder.eternal-september.org!nntp-feed.chiark.greenend.org.uk!ewrotcd!newsfeed.xs3.de!news.jacob-sparre.dk!franka.jacob-sparre.dk!pnx.dk!.POSTED.rrsoftware.com!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Is this actually possible? Date: Wed, 11 Dec 2019 13:55:53 -0600 Organization: JSA Research & Innovation Message-ID: References: <36d45c82-2a6b-4c60-baeb-1a4aef5189c7@googlegroups.com> <69c7677b-4aec-4db2-b240-de6b69f762b9@googlegroups.com> Injection-Date: Wed, 11 Dec 2019 19:55:54 -0000 (UTC) Injection-Info: franka.jacob-sparre.dk; posting-host="rrsoftware.com:24.196.82.226"; logging-data="19020"; mail-complaints-to="news@jacob-sparre.dk" X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.7246 Xref: reader01.eternal-september.org comp.lang.ada:57708 Date: 2019-12-11T13:55:53-06:00 List-Id: "Lucretia" wrote in message news:69c7677b-4aec-4db2-b240-de6b69f762b9@googlegroups.com... > On Wednesday, 11 December 2019 17:38:40 UTC, Dmitry A. Kazakov wrote: >> On 2019-12-11 17:43, Lucretia wrote: ... >> > The idea is to export an array of tagged types as a C array to either a >> > function or a variable / struct element. i.e. >> >> Ada objects of tagged types have varying size and keep tag inside. Both >> make them utterly incompatible with C. > > I know this, but as the compiler let it go through, I wondered if the tag > would be stored elsewhere and not with the tagged type. Otherwise, > shouldn't the compiler complain? I don't know of any reason that a tagged record couldn't be compatible with C. It's just a record with an extra component for the tag, so if an untagged record would be compatible, then the same tagged record would be, too. (Of course, C couldn't do anything with the tag.) Many Ada compilers let one move the tag to other locations (by using a record rep. clause to put the other components in specific places). I don't believe that GNAT supports that, however. But the C could use a junk field to take up the space of the tag to get the representations to match. I'm not aware of any Ada compilers that can store the tag outside of the record. The need for tag re-emergence makes that nearly impossible (one would have to prove that no one ever will convert the type to a class-wide type anywhere in the program before it would be safe to put the tag outside of the object). One can argue about the wisdom of requiring re-emergence in these cases, but we're stuck it (and some people think it is a good thing). Randy.