【问题标题】:convert a C Enum to the delphi?将 C 枚举转换为 delphi?
【发布时间】:2010-11-15 13:46:51
【问题描述】:

我为 C 枚举写了一个 delphi 数字,你能回答我吗,我可能在哪里出错? 有什么问题吗?

C:

 typedef  enum {
   AttributeStandardInformation = 0x10,
   AttributeAttributeList = 0x20,
   AttributeFileName = 0x30,
   AttributeObjectId = 0x40,
   AttributeSecurityDescriptor = 0x50,
   AttributeVolumeName = 0x60,
   AttributeVolumeInformation = 0x70,
   AttributeData = 0x80,
   AttributeIndexRoot = 0x90,
   AttributeIndexAllocation = 0xA0,
   AttributeBitmap = 0xB0,
   AttributeReparsePoint = 0xC0,
   AttributeEAInformation = 0xD0,
   AttributeEA = 0xE0,
   AttributePropertySet = 0xF0,
   AttributeLoggedUtilityStream = 0x100

} ATTRIBUTE_TYPE

和转换的delphi枚举:

ATTRIBUTE_TYPE=( AttributeStandardInformation = $10,
   AttributeAttributeList = $20,
   AttributeFileName = $30,
   AttributeObjectId = $40,
   AttributeSecurityDescriptor = $50,
   AttributeVolumeName = $60,
   AttributeVolumeInformation = $70,
   AttributeData = $80,
    //AttributeData1 = $0,    // has a problem
   AttributeIndexRoot = $90,
   AttributeIndexAllocation = $A0,
   AttributeBitmap = $B0,
   AttributeReparsePoint = $C0,
   AttributeEAInformation = $D0,
   AttributeEA = $E0,
   AttributePropertySet = $F0,
   AttributeLoggedUtilityStream = $100,
    );

【问题讨论】:

  • 至少最后一个 ',' 必须删除。
  • 是什么让您认为自己犯了错误?描述您遇到的问题。

标签: delphi


【解决方案1】:

在 C 中,枚举至少为 4 个字节,您可以使用 Delphi 中的 {$MINENUMSIZE 4} 指令来实现。

如前所述,除了最后一个逗号之外,您的转换是正确的。虽然有时将枚举转换为数字常量会更好,因为在 C 中枚举值和整数是可互换的,而在 Delphi 中并非如此(您当然可以将枚举转换为整数,反之亦然)。

【讨论】:

    【解决方案2】:

    看起来不错,除了中间被注释掉的元素。你遇到了什么问题?

    【讨论】:

    • 不,我的问题不是逗号,我将 c 中的系统程序转换为 delphi,我认为我的问题是 Enum 类型
    • 不,我的问题不是逗号,我将 c 中的系统程序转换为 delphi,我认为我的问题是 Enum 类型?你怎么看 - 两个结构在所有参数、内存空间和....中都相同。
    【解决方案3】:

    我不知道您所说的“有问题”是什么意思,但是如果我删除 AttributeLoggedUtilityStream = $100 之后的逗号,我可以编译您转换后的类型。

    【讨论】:

      猜你喜欢
      • 2020-08-21
      • 1970-01-01
      • 2011-01-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-08-12
      • 1970-01-01
      相关资源
      最近更新 更多