Recent

Author Topic: Enumeration with values  (Read 3831 times)

Abelisto

  • Jr. Member
  • **
  • Posts: 91
Enumeration with values
« on: February 27, 2016, 02:13:30 am »
Inspired by question from StackOverflow.

Lets say I declare enumeration type like

Code: Pascal  [Select][+][-]
  1. TFoo = (
  2.   One = -10,
  3.   Two = 5,
  4.   Three = 15);
  5.  

Is there any way to
1) get the real count of values (3) instead of whole range from -10 to 15?
2) get the index of the value like GetIndex(TFoo.Two) = 1(2)?
3) and vice versa, associate 1(2) to TFoo.Two?

PS: TypeInfo(TFoo) does not compiled with error 'No type info for ...'.
OS: Linux Mint + MATE, Compiler: FPC trunk (yes, I am risky!), IDE: Lazarus trunk

Cyrax

  • Hero Member
  • *****
  • Posts: 836
Re: Enumeration with values
« Reply #1 on: February 27, 2016, 07:32:23 am »
FPC can't create RTTI for such enumeration type.

Check this bug report out : http://bugs.freepascal.org/view.php?id=27622

 

TinyPortal © 2005-2018