Greetings from New Zealand,
It appears to me that in some situations gpc refuses to compile because it loses information about enumerated types defined in units. I'm using gpc version 19990118, based on gcc-2.8.1, under linux. (I gave up on using gpc under OS/2).
Below is a minimal example--about 50 lines of source code divided across 2 units and a main program, all in separate files. Please tell me if I've done something wrong or if you know of a work-around. Thanks,
Jeff Miller miller@otago.ac.nz http://psy.otago.ac.nz/miller
Unit gnutstb1; { this unit is in file gnutstb1.pas }
Interface
Type MyType = (eenie, meenie, minie, mo, eenie2, meenie2, minie2, mo2, eenie3, meenie3, minie3, mo3, eenie4, meenie4, minie4, mo4, eenie5, meenie5, minie5, mo5, eenie6, meenie6, minie6, mo6, eenie7, meenie7, minie7, mo7, eenie8, meenie8, minie8, mo8, eenie9, meenie9, minie9, mo9 );
Basic = Object BoolArr : Array[MyType] of Boolean; Constructor Construct; End;
Implementation
Constructor Basic.Construct; Begin BoolArr[eenie] := True; BoolArr[meenie] := False; BoolArr[minie] := False; BoolArr[mo] := False; End;
End. { end of file gnutstb1.pas }
Unit gnutstb2; { this unit is in file gnutstb2.pas }
Interface
Uses gnutstb1;
Type
Derived1 = Object(Basic) Unused : Char; Constructor Construct; End;
Implementation
Constructor Derived1.Construct; Begin Basic.Construct; BoolArr[meenie] := True; End;
End. { end of file gnutstb2.pas }
Program GnuTstB3; { This main program is in file gnutstb3.pas }
Uses gnutstb1, gnutstb2;
Type Derived2 = Object(Derived1) Unused2 : Char; Constructor Construct; End;
Constructor Derived2.Construct; Begin Derived1.Construct; BoolArr[minie] := True; { gpc says "type mismatch in array index" } End;
Var D2 : Derived2;
Begin D2.Construct; If D2.BoolArr[minie] { gpc again says "type mismatch in array index" } Then Writeln('True') Else Writeln('False'); End. { end of file gnutstb3.pas }
When I issue the command
gpc gnutstb3.pas --automake --borland-pascal
I get the output
gnutstb3.pas: In function `Derived2_Construct': gnutstb3.pas:17: type mismatch in array index gnutstb3.pas: In function `program_Gnutstb3': gnutstb3.pas:24: type mismatch in array index
These files were made OK (as far as I can tell): gnutstb1.o gnutstb2.gpi gnutstb1.gpi gnutstb2.o
9-Mar-00 11:44 you wrote:
Greetings from New Zealand,
It appears to me that in some situations gpc refuses to compile because it loses information about enumerated types defined in units. I'm using gpc version 19990118, based on gcc-2.8.1, under linux.
Arrgh. Why you are using this obseleted version ???
(I gave up on using gpc under OS/2).
I'm never tried to use GPC under OS/2 ...
Below is a minimal example--about 50 lines of source code divided across 2 units and a main program, all in separate files. Please tell me if I've done something wrong or if you know of a work-around.
Sample works like a charm here with gpc 19991030 based on gcc 2.95.2 ...