comp.lang.ada
 help / color / mirror / Atom feed
From: 100331.2264@compuserve.com (R.J. Kirkbride)
Subject: Help with alignment of record types (GNAT)
Date: 1996/04/29
Date: 1996-04-29T00:00:00+00:00	[thread overview]
Message-ID: <4m31pu$9br@dub-news-svc-5.compuserve.com> (raw)


I have been defining the following structure in GNAT (3.01) under
Linux:

	max_size : constant := 10;
	subtype relative_index is natural range 0 .. max_size;

	type text (maximum_length : relative_index) is
	record
		length : relative_index := 0;
		value : string (1 .. maximum_length;
	end record;

By my calculations this structure should take
4 + 4 + 10 bytes = 18 bytes.
However, despite efforts with alignment clauses and representation
clauses on 'text', I cannot stop it making the structure 20 bytes
in size. This is I assume so that is can make it a whole number
of 32 bit words.
(It works as expected with 'max_size' set to 12)
I thought a pragma pack would do it - but no so much luck.

I cannot just do a "for text'size use 144" because the size should
vary at run time if I declare "new text"s with different sizes.

Any help would be most appreciated,

Rob






                 reply	other threads:[~1996-04-29  0:00 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed
replies disabled

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