Ok, I got it wrong with my previous question about enumerations, but what about this:
(file babyunit2)
unit babyunit2;
interface
type MyType = (a,b,c);
implementation
end.
(file babyunit)
unit babyunit;
interface uses babyunit2;
procedure printmytype(b : mytype);
implementation
procedure printmytype(b : mytype); begin writeln(ord(b)); end;
end.
(file baby)
program baby;
uses babyunit,babyunit2;
var x : mytype;
begin for x:=a to c do printmytype(x); end.
[root@twentyfour aargh]# gpc -g -c -w babyunit2.pas [root@twentyfour aargh]# gpc -g -c -w babyunit.pas [root@twentyfour aargh]# gpc baby.pas babyunit2.o babyunit.o -o baby baby.pas: In function `program_Baby': baby.pas:19: incompatible type for argument 1 of `Printmytype'
However, when I combine all three files like this:
program baby;
type MyType = (a,b,c);
procedure printmytype(b : mytype); begin writeln(ord(b)); end;
var x : mytype;
begin for x:=a to c do printmytype(x); end.
Everything works fine. Surely this has to be a compiler problem?
Jo Dillon wrote:
[...] baby.pas:19: incompatible type for argument 1 of `Printmytype' [...] Surely this has to be a compiler problem?
Indeed. :-(
I am currently re-implementing the whole GPI mechanism (which is responsible for the transport of const/type/var/whatever information between units and programs). For the moment, please try to work around this bug, for instance by using integer constants (a=0, b=1, c=2) instead of enumerated types.
Peter
I don't suppose you could give any idea how long that reimplementation is likely to take?
Peter Gerwinski (peter@gerwinski.de) spake thusly:
I am currently re-implementing the whole GPI mechanism (which is responsible for the transport of const/type/var/whatever information between units and programs). For the moment, please try to work around this bug, for instance by using integer constants (a=0, b=1, c=2) instead of enumerated types.
Peter
Jo Dillon wrote:
I don't suppose you could give any idea how long that reimplementation is likely to take?
I'd feel much better if I knew that :-(having flu right now).
The problem is the following (I hope I do not overlook anything):
* GPI files serve to store precompiled source, so-called "tree nodes" in a file. These tree nodes form a highly recursive data structure, pointing back to itself, etc.
* Currently, some high-level tree node structures (e.g. variable and function declarations) are re-compiled rather than retrieved verbatim. The idea was to simplify the GPI file; the result is that GPC slows down when loading a GPI file.
* When one unit imports a type from another one, the inner structure of that type is copied into the outgoing GPI file. This causes incompatibilities between one and the same type, when transported through two GPI files.
The current idea to solve the problems is to simplify the GPI mechanism:
* Do not re-compile anything, but store everything verbatim.
* Do not duplicate anything, but point to another GPI file instead.
In order to make the second item work, every identifier, data type, etc. must "know" in which unit it was declared. That's a lot of work.
Any help is welcome.
Peter