comp.lang.ada
 help / color / mirror / Atom feed
* Help with alignment of record types (GNAT)
@ 1996-04-29  0:00 R.J. Kirkbride
  0 siblings, 0 replies; only message in thread
From: R.J. Kirkbride @ 1996-04-29  0:00 UTC (permalink / 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






^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1996-04-29  0:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-04-29  0:00 Help with alignment of record types (GNAT) R.J. Kirkbride

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