[fpc-pascal] FPC's behavior regarding new TObject methods

Michael Van Canneyt michael at freepascal.org
Sat Nov 13 14:28:09 CET 2010



On Sat, 13 Nov 2010, Sven Barth wrote:

> Hello together!
>
> I've installed FPC 2.4.2 and after reading the page about the changes since 
> 2.4.0, I've compiled Lazarus and noticed a warning in imglist.pp regarding a 
> Equals method (already reported). Now I remembered that 
> http://wiki.freepascal.org/User_Changes_2.4.2#TObject_class_declaration 
> mentions that FPC warns in mode delphi, but generates an error in mode 
> objfpc. So I looked at the top of the unit, but did found "{$mode objfpc}".
>
> Puzzled, I wrote the following test program:
>
> ==== source begin ====
>
> ==== source end ====
>
> Compiling it with FPC 2.4.2 (and 2.5.1 as well) results only in warnings 
> regarding the methods Equals and ToString and not errors as expected after 
> reading the wiki.
>
> So who is right?
> a) the wiki (thus there is a bug in FPC - very bad, because 2.4.2 is already 
> released)
> b) the compiler (thus the wiki is wrong)

The compiler is right. You can always re-introduce methods.
But if you call 'TObject.Equals', your (wrongly declared) method will not be called.
Standard OOP inheritance/overriding rules.

Michael.



More information about the fpc-pascal mailing list