将结构转换为Delphi记录 - 联合

时间:2015-02-07 19:32:33

标签: c++ c delphi struct

如何将union结构转换为Delphi记录?

这是C ++结构

union {
    struct {
        uint32_t  l_i_reserved1;
    } linux1;
    struct {
        uint32_t  h_i_translator;
    } hurd1;
    struct {
        uint32_t  m_i_reserved1;
    } masix1;
} osd1;             /* OS dependent 1 */

这是我的尝试,但我不认为这是对的?

osd1 : Record
  case Cardinal of
    0: (l_i_reserved1 : Cardinal);
    1: (h_i_translator : Cardinal);
    2: (m_i_reserved1 : Cardinal);
  end;

我还需要将此结构转换为Record

union {
    struct {
        uint8_t l_i_frag;   /* Fragment number */
        uint8_t l_i_fsize;  /* Fragment size */
        uint16_t    i_pad1;
        uint16_t    l_i_uid_high;   /* these 2 fields    */
        uint16_t    l_i_gid_high;   /* were reserved2[0] */
        uint32_t    l_i_reserved2;
    } linux2;
    struct {
        uint8_t h_i_frag;   /* Fragment number */
        uint8_t h_i_fsize;  /* Fragment size */
        uint16_t    h_i_mode_high;
        uint16_t    h_i_uid_high;
        uint16_t    h_i_gid_high;
        uint16_t    h_i_author;
    } hurd2;
    struct {
        uint8_t m_i_frag;   /* Fragment number */
        uint8_t m_i_fsize;  /* Fragment size */
        uint16_t    m_pad1;
        uint32_t    m_i_reserved2[2];
    } masix2;
} osd2;                 /* OS dependent 2 */

相同的概念是否适用?

由于

0 个答案:

没有答案