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 10.25.217.213 with SMTP id s82mr2339091lfi.9.1466475627744; Mon, 20 Jun 2016 19:20:27 -0700 (PDT) X-Received: by 10.157.39.133 with SMTP id c5mr580549otb.6.1466475627651; Mon, 20 Jun 2016 19:20:27 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!goblin1!goblin.stu.neva.ru!oe3no6567269lbb.1!news-out.google.com!di11ni13391lbb.1!nntp.google.com!oe3no6567268lbb.1!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Mon, 20 Jun 2016 19:20:27 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=216.121.226.25; posting-account=ENgozAkAAACH-stq5yXctoDQeZQP2E6J NNTP-Posting-Host: 216.121.226.25 References: <66c14298-c62d-4f4b-b0c0-e969454f9334@googlegroups.com> <2e39857a-7121-476b-807a-d2bff1e598f4@googlegroups.com> <431af616-7df3-4e4d-9262-26ed68cb74c7@googlegroups.com> <037df2b8-b9c4-4447-87ee-cc89d7072b30@googlegroups.com> <15914c54-191c-4f37-b754-282855d1aeaf@googlegroups.com> <3e25c9a0-469c-4487-b78e-6f87434f87fa@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <2e69ca6f-484c-4d58-b0fe-d17a744b1418@googlegroups.com> Subject: Re: Generic Embedded List Nodes From: Warren Injection-Date: Tue, 21 Jun 2016 02:20:27 +0000 Content-Type: text/plain; charset=UTF-8 Xref: news.eternal-september.org comp.lang.ada:30847 Date: 2016-06-20T19:20:27-07:00 List-Id: On Monday, 20 June 2016 15:33:16 UTC-4, Niklas Holsti wrote: > On 16-06-20 15:26 , Warren wrote: > > > Anyway folks- thanks for your help but I now have a working solution. I'm signing off this thread. > > Before signing off, do please describe your solution. I thought I had the problem licked using the following generic Object_Of function, but when I whipped up an example, the compile problem returned (or there was pilot error): function Object_Of( Node: access Emb_Node; Member: Natural ) return Object_Type is use System.Storage_Elements; A: constant System.Address := Node.all'Address; B: constant System.Address := A - Storage_Offset(Member); R: Object_Type; for R'Address use B; pragma Import(Convention => Ada, Entity => R); begin return R; end Object_Of; The compiler is complaining with: warning: controlled object "R" must not be overlaid. The test record looks like this: type My_Recd is record ID: Natural; Node: aliased Emb_Node; Name: Unbounded_String; end record; and the Emb_Node looks like this: type Emb_Node is record Next: access Emb_Node; Prev: access Emb_Node; end record; The Node member is one culprit because it has two Access members (which count as members needing initialization). Unbounded_String may be another factor. What is particularly galling about this is that the record already exists, and does NOT need initialization at this point. All I need the compiler do is return it to me based upon its address. Arg! To accomplish this, I may have to resort to invoking a C function. But I don't think that will work either. Not by System.Address at least. More head scratching to follow. Warren