comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: TYPE'Size in static expression
Date: Fri, 21 Oct 2005 10:55:03 +0200
Date: 2005-10-21T10:55:07+02:00	[thread overview]
Message-ID: <p06ipbbj9t3d.15cu37vh2fjuo.dlg@40tude.net> (raw)
In-Reply-To: 4358A12B.4030601@dif.andthis.um.es

On Fri, 21 Oct 2005 10:04:59 +0200, Francisco J. Montoya wrote:

> I'm trying to write a generic (container) package whose only parameter 
> is a type BaseType. I need to define an array of elements of this type 
> (some kind of buffer) but I'd like the size of this buffer to be 
> approximately constant regardless of the size of each BaseType element. 
> My first attempt was to make some definitions like the following:
> 
>   Buffer_Size : constant := 1024; -- 1Kb buffer
>   Num_Elements : constant := 8 * Buffer_Size / BaseType'Size; -- Wrong!

Num_Elements : constant Integer :=
   8 * Buffer_Size / BaseType'Size;

>   type Buffer is array (1..Num_Elements) of BaseType;

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



  reply	other threads:[~2005-10-21  8:55 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-10-21  8:04 TYPE'Size in static expression Francisco J. Montoya
2005-10-21  8:55 ` Dmitry A. Kazakov [this message]
2005-10-21 22:09   ` Jeffrey R. Carter
2005-10-24 10:56   ` Francisco J. Montoya
2005-10-24 11:45     ` Dmitry A. Kazakov
2005-10-24 19:15     ` Jeffrey R. Carter
2005-10-24 20:15       ` Robert A Duff
replies disabled

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