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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,26aa6d7095c151 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-10-18 14:30:02 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!news-fra1.dfn.de!news-mue1.dfn.de!newsfeed.stueberl.de!cox.net!newsfeed1.earthlink.net!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!newsread1.prod.itd.earthlink.net.POSTED!not-for-mail Message-ID: <3DB07D49.6090407@acm.org> From: Jeffrey Carter User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.0.0) Gecko/20020530 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Porting from Modula-2 to Ada References: <3DAFC542.152C0EE0@lml.ls.fi.upm.es> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Date: Fri, 18 Oct 2002 21:29:13 GMT NNTP-Posting-Host: 63.184.0.95 X-Complaints-To: abuse@earthlink.net X-Trace: newsread1.prod.itd.earthlink.net 1034976553 63.184.0.95 (Fri, 18 Oct 2002 14:29:13 PDT) NNTP-Posting-Date: Fri, 18 Oct 2002 14:29:13 PDT Organization: EarthLink Inc. -- http://www.EarthLink.net Xref: archiver1.google.com comp.lang.ada:29925 Date: 2002-10-18T21:29:13+00:00 List-Id: Lutz Donnerhacke wrote: > generic > type T(<>) is limited private; > procedure Xxx (data : T); > > procedure Xxx (data : T) is > use System.Storage_Elements; > raw : Storage_Array (Storage_Offset'First .. > Storage_Offset'First + (data'Size + Storage_Unit - 1) / Storage_Unit); > pragma Import (Ada, raw); > for raw'Address use data'Address; > begin > ... System.Storage_Elements.Storage_Array is the best way to deal with untyped storage in Ada. This example is almost right; it seems to allocate one more Storage_Element than it should. A better way to achieve the same thing would be Raw : Storage_Array (1 .. Data'Max_Size_In_Storage_Elements); which avoids such off-by-one errors. -- Jeff Carter "Now look, Col. Batguano, if that really is your name." Dr. Strangelove