[fpc-pascal] using oldlinux
Michael Van Canneyt
michael at freepascal.org
Tue Jun 14 09:46:43 CEST 2005
On Tue, 14 Jun 2005, Koenraad Lelong wrote:
> Hi,
> Anyone has suggestions why I can't compile the following :
>
> unit test1;
>
> interface
>
> function ReadCOM(portnum : integer; inlen : integer; var inbuf : array of
> byte) : integer;
>
> implementation
>
> uses baseunix, oldlinux;
You must switch the order of the units, because you get the 'oldlinux' types which
you try to use in 'baseunix' functions.
You can drop the oldlinux altogether. The program compiles as follows:
uses baseunix,unixtype;
function ReadCOM(portnum : integer; inlen : integer; var inbuf : array of byte) : integer;
var
fd : integer;
filedescr : TFDSet;
tval : timeval;
cnt : integer;
timeout : boolean;
begin
fpFD_ZERO(filedescr);
fpFD_SET(fd,filedescr);
tval.tv_sec:=0;
tval.tv_usec:=10000;
if fpSelect(fd+1, at filedescr,nil,nil, at tval)>0 then
if fpread(fd,inbuf[cnt],1)<>1 then
timeout:=true
else
inc(cnt)
else timeout:=true;
if not timeout then
ReadCom:=inlen
else
ReadCom:=cnt;
end;
begin
end.
More information about the fpc-pascal
mailing list