[fpc-pascal]About order of units...

Michalis Kamburelis michalis at arthur
Sat Aug 30 19:08:57 CEST 2003


L D Blake wrote:

> Ok, still messing with this silly problem...
> 
> Now the question is about order of declaration in units...
> 
> Lets say I wrote a unit "WinFix" with some of these cursed range checking
> problems cleaned up... am I correct in assuming that if I added it to my units
> list like this:
> 
>         Uses
>           Windows,
>           Winfix,
>           <my units>;
> 
> The dupicate definitions in the WinFix unit would replace those in the Windows
> unit?
> 
> ---
> L D Blake
> 
> 

Yes. Identifiers in Windows unit will be hidden by same identifiers in
WinFix unit.

Beware of one "catch" : if you have two functions/procedures with the same names, one in the Windows unit and one in the WinFix unit
_and they are declared as overloaded_ (i.e. using Delphi's style, with "overload" keyword) then Delphi and FPC 1.1 will be doing "cross-unit overloading" - this is the only case when identifier from WinFix will NOT hide the same identifier from Windows, intead they will co-exist in one namespace. However, this is not implemented in FPC 1.0.x so if you use only FPC 1.0.x there's nothing to worry (however you should be aware of this if you're writing some non-testing code, that you might want to compile some day with FPC 1.1 or higher).

Regards,
Michalis Kamburelis
<michalis at camelot.homedns.org>
http://www.camelot.homedns.org/~michalis/








More information about the fpc-pascal mailing list