[fpc-devel] Generic List in Advanded record does not compile with -MobjFPC, works with -MDelphi (perhaps related to Generics.Collections that I am using)

Michael Ring mail at michael-ring.org
Mon Apr 27 23:26:57 CEST 2015


I now officially feel stupid, this now works with the ; in place, I 
could have sworn that I have tried this......

But two lines deeper I end up with a new problem now:

   TSpecialFunctionRegisterComparer = 
class(TComparer<TSpecialFunctionRegister>)
     function Compare(constref Left, Right: TSpecialFunctionRegister): 
Integer; override;
   end;

Error: class type expected, but got "TComparer"
Fatal: class type expected, but got "TComparer"

Is this a similar problem?

If yes then I guess I will need to stay with -Mdelphi the specialize 
syntax is not availabe in delphi mode (identifier not found 
"specialize") and the generics library where TComparer comes from 
explicitly sets delphi mode.

Michael

Am 27.04.15 um 22:34 schrieb Jeppe Johansen:
> There's a missing ; after the specialization
> ,
> On 04/27/2015 09:46 PM, Michael Ring wrote:
>> Did not work, now I get
>>
>> Fatal: Syntax error, ";" expected but "identifier PUBLIC" found
>>
>> I did a cut & paste of your code into my code
>>
>> Michael
>>
>> Am 27.04.15 um 21:19 schrieb Sven Barth:
>>> On 27.04.2015 20:31, Michael Ring wrote:
>>>> Argh, soory, cut & waste error, this is the correct thing:
>>>>
>>>>    TSpecialFunctionRegister = record
>>>>      name: String;
>>>>      device: String;
>>>>      address: longWord;
>>>>      bits: TList<TSpecialFunctionBits>;
>>>>      constructor create(theName: String; theAddress: longWord);
>>>>    end;
>>>>
>>>
>>> As I expected. Try this:
>>>
>>> === code begin ===
>>>
>>> TSpecialFunctionRegister = record
>>> public type
>>>   TSpecialFunctionBitsList = specialize TList<TSpecialFunctionBits>
>>>   // alternatively you could declare that outside of the record as 
>>> well if you need it more often
>>> public
>>>   name: String;
>>>   device: String;
>>>   address: LongWord;
>>>   bits: TSpecialFunctionBitsList;
>>>   constructor Create(theName: String; theAddress: LongWord);
>>> end;
>>>
>>> === code end ===
>>>
>>> Regards,
>>> Sven
>>> _______________________________________________
>>> fpc-devel maillist  -  fpc-devel at lists.freepascal.org
>>> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
>>
>> _______________________________________________
>> fpc-devel maillist  -  fpc-devel at lists.freepascal.org
>> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
>>
>
> _______________________________________________
> fpc-devel maillist  -  fpc-devel at lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel




More information about the fpc-devel mailing list