Board index » delphi » Delphi equivalent to C's UNION?

Delphi equivalent to C's UNION?

Hi,

  I'm trying to convert some C code that contains the following within a
struct:
        union
        {
                WORD val1;
                WORD va2[2];
        };
  What would the equivalent be in Delphi2?

Thanks,
Mike Hollis
mhol...@primenet.com

 

Re:Delphi equivalent to C's UNION?


As a 1st attempt

type
  someunion = record
    case byte of
        val1 : WORD ;
        va2 : integer;
{or}
            va2 : array1..2] of word;
{WORD va2[2];
  if this means a 2 member array, each member of type word}
  end;

--
Boris Ingram, Cyborg Software
boris...@iafrica.com
100076.3...@compuserve.com
http://www.pcb.co.za/users/borising/cyborg.htm

Mike Hollis <mhol...@primenet.com> wrote in article
<01bc31a8$7feaeae0$c670a...@mike1.primenet.com>...

Quote
> Hi,

>   I'm trying to convert some C code that contains the following within a
> struct:
>    union
>    {
>            WORD val1;
>            WORD va2[2];
>    };
>   What would the equivalent be in Delphi2?

> Thanks,
> Mike Hollis
> mhol...@primenet.com

Other Threads