comp.lang.ada
 help / color / mirror / Atom feed
From: Gerd <GerdM.O@t-online.de>
Subject: Need help for constrained type
Date: Thu, 6 Feb 2014 08:13:28 -0800 (PST)
Date: 2014-02-06T08:13:28-08:00	[thread overview]
Message-ID: <e16cb161-a199-48b1-ac53-a783198da0ac@googlegroups.com> (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.


             reply	other threads:[~2014-02-06 16:13 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-06 16:13 Gerd [this message]
2014-02-06 17:30 ` Need help for constrained type 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
replies disabled

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