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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,2653c85ff3e38d8e,start X-Google-Attributes: gid103376,public From: mheaney@ni.net (Matthew Heaney) Subject: Re: pointers to unconstrained arrays Date: 1997/11/16 Message-ID: #1/1 X-Deja-AN: 290062957 References: <346FC90F.3EEC@vsl.com.au> Organization: Estormza Software Newsgroups: comp.lang.ada Date: 1997-11-16T00:00:00+00:00 List-Id: In article <346FC90F.3EEC@vsl.com.au>, Andrew Kelly wrote: >procedure allocate_buffer ( > low, high : in integer; > buffer_address : system.address; > buffer_ptr : out buffer_ptr_type) is [snip] > -- return pointer to buffer > buffer_ptr := buffer'access; >end allocate_buffer; You can't do this, and for a very good reason. You're pointing to a locally-declared buffer. > > > >-- unconstrained_array_ptr_test > my_buffer_ptr : buffer_ptr_type; > >begin > allocate_buffer(1, 5, system.ItoA(16#B000#), my_buffer_ptr); Why not do this Buffer : Buffer_Type (1 .. 5); for Buffer'Address use System.ItoA (16#B000#); begin and then refer to Buffer directly? If you're going to call Allocate_Buffer with hard-coded parameters, and declare a buffer access type to indirectly refer to the buffer, you might as well just declare a buffer directly, using the parameters you passed to the call. -------------------------------------------------------------------- Matthew Heaney Software Development Consultant (818) 985-1271