comp.lang.ada
 help / color / mirror / Atom feed
From: "Martin Dowie" <martin.dowie@btopenworld.com>
Subject: Re: Variant Record Sizes..
Date: Thu, 19 Aug 2004 19:29:51 +0000 (UTC)
Date: 2004-08-19T19:29:51+00:00	[thread overview]
Message-ID: <cg2v3f$73h$1@sparta.btinternet.com> (raw)
In-Reply-To: e8f9995c.0408191048.5d250173@posting.google.com

Ganesh Ramasivan wrote:
> Hello,
>
> I am having a hard time understanding variant records with regard to
> memory usage. Does the size of the record become the size of the
> largest element in that record?
>
> So in case of the example below, is the size of the Test_Record 2
> bytes, even though the "use 8" clause has been specified as the other
> element of the record specifies "use 16".
>
> Any input will be appreciated.

Couple of things:
     Test_Record : TEST_ICP_POI_MESSAGE_TYPE(STATE_1);

Constrains "Test_Record" to always be a subtype of TEST_ICP_POI_MESSAGE_TYPE
constrained to "STATE_1".

Because you didn't supply a default value to the descriminant you can never
change which variant you want Test_Record to be:

Both these things mean that the compile 'knows' that Test_Record need only
be 2 bytes long.

So,

1) Add a default to the descriminant if you every what to change which
variant you want the variable to take; and
2) Don't constrain the variable at declaration time.

Cheers

-- Martin





  reply	other threads:[~2004-08-19 19:29 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-08-19 18:48 Variant Record Sizes Ganesh Ramasivan
2004-08-19 19:29 ` Martin Dowie [this message]
2004-08-20 14:09   ` Ganesh Ramasivan
2004-08-19 19:30 ` 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