comp.lang.ada
 help / color / mirror / Atom feed
* Need help for constrained type
@ 2014-02-06 16:13 Gerd
  2014-02-06 17:30 ` Niklas Holsti
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Gerd @ 2014-02-06 16:13 UTC (permalink / raw)


Hello,

can someone help me? 

This is my problem:

I have a record containing a constrainted array. I can write it like this:


  type Mem_Array is array (Natural range <>) of Short_Integer;

  type Memory_Block (len : Natural) is
    record
      Start_Address : Mem_Addr;
      Block_Size : Natural;
      Usage_Info : Mem_Array (1..len);
    end record;

  mem : Memory_Block (2**16);  --  for example


But i would like the indices of Usage_Info running from 0..len - 1 (C-style). But when I write

  type Memory_Block (len : Natural) is
    record
      Start_Address : Mem_Addr;
      Block_Size : Natural;
      Usage_Info : Mem_Array (0..len-1);
    end record;

the compiler tells me that this is not allowed.

Is it possible to allocate "len" units, but address them from 0 .. len - 1?

How can I do this?

Thanks.


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2014-02-10 11:40 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-06 16:13 Need help for constrained type Gerd
2014-02-06 17:30 ` Niklas Holsti
2014-02-06 18:03   ` adambeneschan
2014-02-06 18:37     ` Niklas Holsti
2014-02-06 18:57       ` adambeneschan
2014-02-06 17:37 ` G.B.
2014-02-07 14:11   ` Mike H
2014-02-10 11:40     ` G.B.
2014-02-07  0:04 ` Jeffrey Carter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox