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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,35ee0472de38e833 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2000-12-13 00:58:01 PST Path: supernews.google.com!sn-xit-02!supernews.com!isdnet!isdnethub!tgi From: tgi@tgi2.dev.netgem.com (Tristan Gingold) Newsgroups: comp.lang.ada Subject: Re: Variable length raw-byte data Date: 13 Dec 2000 08:56:32 GMT Message-ID: References: <976563484.10868.0.nnrp-01.c1ed21d4@news.demon.co.uk> <916h4j$egt$1@nnrp1.deja.com> Reply-To: tgi@netgem.com NNTP-Posting-Host: gw.netgem.com X-Trace: news6.isdnet.net 976697792 55445 195.154.83.69 (13 Dec 2000 08:56:32 GMT) X-Complaints-To: abuse@isdnet.net NNTP-Posting-Date: 13 Dec 2000 08:56:32 GMT User-Agent: slrn/0.9.6.3 (Linux) Xref: supernews.google.com comp.lang.ada:3049 Date: 2000-12-13T08:56:32+00:00 List-Id: In article <916h4j$egt$1@nnrp1.deja.com>, Robert Dewar wrote: >In article ><976563484.10868.0.nnrp-01.c1ed21d4@news.demon.co.uk>, > "Julian Morrison" wrote: >> I'm trying to shim to a C library that returns some data as a >length in >> bytes and a pointer to the first byte. The length is not known >at compile >> time. Is there any way I can morph this into an array of mod >2**8? I'm >> using the latest Linux GNAT. > > > >The important thing is to NEVER use pointers to unconstrained >arrays in such a case. this is asking for non-portable, peculiar >behavior. > >A good type to use in this case is what we in GNAT-land call >big arrays: > > type byte is mod 2 ** 8; > > type memory is array (natural) of byte; > type memptr is access memory; > >Now it is almost certainly safe to use address_to_access >conversions to go between address and memptr. AFAIR, address_to_access_conversions has only one generic parameter: the Object. So, you need to use the access type defined by the package. Right or wrong ? Related question: why it is so ? (why AAC doesn't have the same paramaters as unchecked_conversion ?) Tristan.