3

i wrote a delphi Numeric for a C Enum can you answer me , where can i may had a mistake? is there anything wrong?

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

and converted delphi enum:

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,
    );
2
  • 4
    At least the last ',' must be removed.
    – da-soft
    Commented Nov 15, 2010 at 13:54
  • What makes you think you made a mistake? Describe what problem you're having. Commented Nov 15, 2010 at 15:05

3 Answers 3

12

In C an enum is at least 4 bytes, you can use the {$MINENUMSIZE 4} directive in Delphi to achieve the same.

Apart from that last comma, as already mentioned, your conversion is correct. Although sometimes it's better to translate an enum as numeric constants since in C an enum value and an integer are interchangeable which is not the case in Delphi (you can of course cast an enum to an integer and vice versa).

0
1

That looks right, aside from the commented-out element in the middle. What sort of problems are you having with it?

2
  • no my problem isnot comma i convert a system program in c to delphi and i think my problem is in Enum type
    – micheal
    Commented Nov 15, 2010 at 14:08
  • no my problem isnot comma i convert a system program in c to delphi and i think my problem is in Enum type ? what do you think - is two structure same in all parameters , space in memory and ....
    – micheal
    Commented Nov 15, 2010 at 14:09
1

I have no idea what you mean with "has a problem", but if I remove the comma after AttributeLoggedUtilityStream = $100 I can compile your converted type.

Not the answer you're looking for? Browse other questions tagged or ask your own question.