开发者

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开发者_JAVA技巧:1;
  unsigned int reserved0:1;
  unsigned int f30:1;
  unsigned int f29:1;
 }frame;
}rfun_gop_event_info;

Thank you.


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;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜