* Re: pointers to unconstrained arrays
[not found] <346FC90F.3EEC@vsl.com.au>
@ 1997-11-16 0:00 ` Matthew Heaney
1997-11-17 0:00 ` Keith Thompson
0 siblings, 1 reply; 2+ messages in thread
From: Matthew Heaney @ 1997-11-16 0:00 UTC (permalink / raw)
In article <346FC90F.3EEC@vsl.com.au>, Andrew Kelly <andrewk@vsl.com.au> 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
<mailto:matthew_heaney@acm.org>
(818) 985-1271
^ permalink raw reply [flat|nested] 2+ messages in thread