I am experimenting with gpc 20021128 built with gcc 3.2.1. However I have a compilation problem. The following code fails to compile with the error message:
ml.p:12: passing arg1 of Sys_stat from incompatible array.
The code compiles OK under 20020426 based on gcc 2.95.2.
Am I doing something wrong or is this a bug? (Note if the function rmdir line is commented out in ml2 then the program compiles. If the code of ml2 is merged with ml then the code compiles).
unit ml2;
interface
Const CstrSize = 254;
type
StatRecord = Array[1..20] of Integer; CstrIndex = 1..CstrSize+1; Cstring0 = packed array [CstrIndex] of char;
function Cstr(protected S: string): Cstring0;
function rmdir(protected Path: Cstring0): integer; C_language;
function sys_stat(protected Path: Cstring0; var Buf: StatRecord): integer; asmname 'stat';
implementation
function Cstr;
var I, U: CstrIndex; Result: Cstring0;
begin U := length(S); if U > CstrSize then U := CstrSize; for I := 1 to U do Result[I] := S[I]; Result[U+1] := chr(0); Cstr := Result; end { Cstr };
end.
Program ml;
uses gpc, { cstrings,} ml2;
procedure make_standard_error(progname:Tstring); var retval1:integer; statrec:statrecord; begin retval1:=sys_stat(Cstr(progname+'.err'),statrec); end;
Begin Writeln('Starting'); Make_standard_error('ml'); end.