Thanks for the answer.
But is that by design ?
Let' look at this case (not the best design, but big legacy):
File common.pas:
uses StandardFile, MacWindows;
...
var MaPict: array[WPictWind_1..WPictWind_3] of PicHandle;
File utils.pas:
uses commons, MacWindows, SegLoad, Quickdraw, StandardFile;
...
var PictRect: Rect;
...
DrawPicture(PictArray[i], PictRect);
Compilation:
Utils.pas(316,29) Error: Incompatible type for arg no. 1: Got "MACWINDOWS.PicHandle", expected "STANDARDFILE.PicHandle"
I know about unit propagation. PicHandle is first defined in MacWindows, then used in standardfile.
The best solution I've found is to suffle units around, altough I find this approach inelegant.
Renaming every occurence of some types is a better solution, altough very intrusive.
Shouldn't type A defined in unit X be fixed whether units Y, Z who also use it are included or not in my program ?
Also when unit Y defines a procedure with type A (from unit X) as parameter, shouldn't type A still refer to the type A as defined in unit X, and not become some types like Y.A ?
It is unclear to me, why this problem occur in the first place (In this case there is no re-definition of the types, as for oldlinux)
Kind regards,
Alain
Vincent Snijders wrote 37 lines
Alain Vitry wrote:
> Le 14 juin 05, à 09:46, Michael Van Canneyt a écrit :
>>
>> You must switch the order of the units, because you get the
>> 'oldlinux' types which
>> you try to use in 'baseunix' functions.
>>
>>
> This unit order trick is a bit of a wizardery to me. It quickly get
> very messy in a large enough program to swap units order until you
> get the one which doesn't break.
> In the sw I'm porting, almost every single UPI type is re-defined in
> many units, which makes FPC complain about types.
> Am I missing some switches or some pascal features, with my kernel
> hacker mind ?
You can also specify from which unit you want to use the
type/procedure/function/constant.
Suppose both unit A and unit B declare a procedure DoIt;
You could do something like this:
program p;
uses A, B;
begin
A.DoIt; // calls DoIt in unit a
B.DoIt; // calss DoIt in unit b
end;
Vincent.
_______________________________________________
fpc-pascal maillist -
http://lists.freepascal.org/mailman/listinfo/fpc-pascal