加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

将C Enum转换为delphi?

发布时间:2020-12-16 10:28:23 所属栏目:百科 来源:网络整理
导读:我为C Enum写了一个delphi数字你能回答我,我在哪里可能有错? 有什么不对的吗? C: typedef enum { AttributeStandardInformation = 0x10,AttributeAttributeList = 0x20,AttributeFileName = 0x30,AttributeObjectId = 0x40,AttributeSecurityDescriptor =
我为C Enum写了一个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,);

解决方法

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

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读