svetlana
svetlana

Reputation: 11

how to translate typedef union to delphi?

1)

typedef union __rfun_gop_event_info
{
 unsigned int evt;
 struct
 {
  unsigned int reserved1:1;
  unsigned int reserved0:1;
  unsigned int f30:1;
  unsigned int f29:1;
 }frame;
}rfun_gop_event_info;

2)

typedef union __rfun_gop_event_info
{
 unsigned int evt;
 struct
 {
  unsigned int reserved1:1;
  unsigned int reserved0:1;
  unsigned int f30:1;
  unsigned int f29:1;
 }frame;
}rfun_gop_event_info;

Thank you.

Upvotes: 1

Views: 2245

Answers (1)

jpfollenius
jpfollenius

Reputation: 16620

Have a look at this article at Delphi Corner that explains variant records which is exactly what you need:

DelphiCorner: Variant Records: The equivalent to the C-union structure

Excerpt containing example:

type
 TPerson = record
   FirstName, LastName: string[40];
   BirthDate: TDate;
   case Citizen: Boolean of
     True: (BirthPlace: string[40]);
     False: (Country: string[20];
       EntryPort: string[20];
       EntryDate: TDate;
       ExitDate: TDate);
 end;

Upvotes: 3

Related Questions