2011-01-10 77 views
1

1)如何將typedef union轉換爲delphi?

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; 

謝謝。

+0

請使用「代碼「功能來呈現您的代碼示例。 – Apalala 2011-01-10 12:11:02

+1

檢查這個問題 - http://stackoverflow.com/questions/282019/how-to-simulate-bit-fields-in-delphi-records – Vladimir 2011-01-10 12:13:31

回答

3

看一看這篇文章德爾福角,說明變種記錄而這正是你所需要的:

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

摘錄例如:

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;