comp.lang.ada
 help / color / mirror / Atom feed
* C-style 'union' in Ada?
@ 2001-08-13  6:06 Brian Catlin
  2001-08-13  7:34 ` tmoran
                   ` (2 more replies)
  0 siblings, 3 replies; 19+ messages in thread
From: Brian Catlin @ 2001-08-13  6:06 UTC (permalink / raw)


I'm still trying to get both lobes around the Ada paradigm.  I have a record that I want to hold a pointer to a buffer which is
either a String or Wide_String, but I don't want to statically declare which, so using a variant record won't work (at least given
my understanding).  Likewise, I don't want to have two record definitions, one for String, and one for Wide_String.  In the package
I'm designing, I don't care whether it is a String or Wide_String, I will just pass it to the file I/O packages (stream, in this
case).  In C, I would:

struct
    {
    ULONG    length;

    union
        {
        STRING_DESC                *ansi_string;
        WIDE_STRING_DESC    *wide_string;
        } strings;
    } string_desc;

and then:

struct
    {
    ...
    string_desc    file_name;
    ...
    } some_struct;

What is the idiom or method to use in Ada?

 -Brian






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

end of thread, other threads:[~2001-08-17 21:36 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-08-13  6:06 C-style 'union' in Ada? Brian Catlin
2001-08-13  7:34 ` tmoran
2001-08-14  3:09 ` DuckE
2001-08-14  3:49   ` Brian Catlin
2001-08-14  7:37     ` Martin Dowie
2001-08-14  9:39       ` Ole-Hjalmar Kristensen
2001-08-14 11:49         ` Martin Dowie
2001-08-14 13:38 ` Ted Dennison
2001-08-16 22:35   ` David Brown
2001-08-17  3:14     ` Brian Catlin
2001-08-17 14:44       ` Ted Dennison
2001-08-17 16:38         ` Jeffrey Carter
2001-08-17 18:17           ` Ted Dennison
2001-08-17 18:45         ` Samuel T. Harris
2001-08-17  3:18     ` Variable sizes for record fields (was: C-style 'union' in Ada) Larry Kilgallen
2001-08-17  6:34       ` Variable sizes for record fields David Brown
2001-08-17 10:44         ` Larry Kilgallen
2001-08-17 19:18           ` Warren W. Gay VE3WWG
2001-08-17 21:36             ` Ken Burtch

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