comp.lang.ada
 help / color / mirror / Atom feed
* Variant record memory storage question
@ 2018-08-01 17:38 NiGHTS
  2018-08-01 18:35 ` Shark8
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: NiGHTS @ 2018-08-01 17:38 UTC (permalink / raw)


Say I had a variant record like this:

type Which_One is (Is_Small, Is_Big);

type Variant_Record (Option : Which_One) is 
record
    case Option is
        when Is_Small =>
            Var_1 : Byte -- 1 byte
        when Is_Big =>
            Var_2 : Some_Large_Record -- 1000 bytes
    end case;
end record;

Will the record Variant_Record( Is_Small ) be stored as 1 byte? Or does it act almost like a C union allocating the memory for Variant_Record( Is_Big ) even though it will never morph at run-time?

I am trying to determine the most memory-efficient way to store a complex record and it seems Variant_Record can help me do this, but I am unsure if it will work the way I think it will.

Note I am using gcc. Thank you.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-08-01 22:30 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-01 17:38 Variant record memory storage question NiGHTS
2018-08-01 18:35 ` Shark8
2018-08-01 18:51   ` NiGHTS
2018-08-01 19:00     ` G.B.
2018-08-01 18:58 ` G.B.
2018-08-01 19:54 ` Niklas Holsti
2018-08-01 22:30 ` Jeffrey R. Carter

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