comp.lang.ada
 help / color / mirror / Atom feed
From: Per Sandberg <per.s.sandberg@bahnhof.se>
Subject: Re: Representation clause of a discriminated record
Date: Wed, 3 Aug 2016 17:22:59 +0200
Date: 2016-08-03T17:22:59+02:00	[thread overview]
Message-ID: <n%noz.14277$OC.7713@fx39.am4> (raw)
In-Reply-To: <nns21p$j1q$1@dont-email.me>

Well
I would add a Aspect/Pragma "pack" as well, since some architectures 
may insert padding to start objects on boundaries /= 32 bit.

    type Discriminated_Record (Size : Natural) is
       record
          A : String (1 .. Size);
       end record with Pack => True;
    for Discriminated_Record use record
       Size at 0 range 0 .. 31;
    end record;
/Per

Den 2016-08-03 kl. 08:13, skrev Jeffrey R. Carter:
> On 08/02/2016 10:04 PM, David SAUVAGE wrote:
>>
>> What would be a valid representation clause for the following discriminated record ? (taken from the Ada wikibook [1])
>>
>>    type Discriminated_Record (Size : Natural) is
>>     record
>>        A : String (1 .. Size);
>>     end record;
>
> for Discriminated_Record use record
>    Size at 0 range 0 .. 31;
> end record;
>
> if Integer'Size = 32. You can't give a representation for A because you don't
> know it's size.
>


  reply	other threads:[~2016-08-03 15:22 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-03  5:04 Representation clause of a discriminated record David SAUVAGE
2016-08-03  6:13 ` Jeffrey R. Carter
2016-08-03 15:22   ` Per Sandberg [this message]
2016-08-03 16:43     ` david.sauvage
2016-08-03 16:46     ` David SAUVAGE
2016-08-04 21:23       ` Randy Brukardt
replies disabled

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