[fpc-devel] Patch for fixing CE compilation

Oro06 orinaudo at gmail.com
Mon Oct 30 10:26:00 CET 2006


Marc Weustink wrote:
> Hi,
>   
hi,
> This patch fixes CE compilation.
> I would have applied it myself, but I've some questions about the common
> win dir and the wince implementation in the rtl.
>
>   
you can apply it
> The main fix was changing the definition of TCHAR=Word into a
> TCHAR=WideChar for UNICODE
>
> This is declared in both wince/wininc/base.inc and win/wininc/base.inc
> I changed them both, since IMO win32/64 would have the same problem if
> UNICODE was defined.
> At the same time I wondered why there are 2 declarations. Why isn't
> wince ising the win definition as well ?
>
>   

> Same counts for instance for socket.pp, why are there 2 ?
>
> Further, not related to this fix, but just noticed it, I commented the
> declatarion of WCHAR in both base.inc.
> AFAICS, WCHAR is defined in systemh and IMO there is no reason to define
> it elsewhere again. I guess more cases are present.
> Is there a reason for this (other than a leftover form the past) ?
>
>   
from ealry stage of arm/wince port api fork was decided moslty for 2 
reasons :
1- not polluting win32 api with too much ifdefs
2- wince sysgen is not the same for wince and win32 (so even for ms it's 
forked)

now , after one year feedback
the fact is that there not so much differences (few consts and records, 
calling convention)
so maybe some cleaning could be done in that way
arm/wince compiler is now running very well, i guess a priorised todo  
for next release could be done :)
 
> Marc
>   
> ------------------------------------------------------------------------
>
> Index: wince/wininc/base.inc
> ===================================================================
> --- wince/wininc/base.inc	(revision 5038)
> +++ wince/wininc/base.inc	(working copy)
> @@ -256,7 +256,7 @@
>       SIZE_T = Cardinal;        //+winnt
>  {$ifdef UNICODE}
>       TBYTE = word;
> -     TCHAR = word;
> +     TCHAR = widechar;
>       BCHAR = word;
>  {$else}
>       TBYTE = byte;
> @@ -265,7 +265,7 @@
>  {$endif}
>  
>       UCHAR = byte;          //windef
> -     WCHAR = WideChar;      //winnt
> +//     WCHAR = WideChar;      //winnt
>  
>       UINT   = Cardinal;     //windef
>       ULONG  = Cardinal;     //windef
> Index: wince/sockets.pp
> ===================================================================
> --- wince/sockets.pp	(revision 5038)
> +++ wince/sockets.pp	(working copy)
> @@ -284,7 +284,7 @@
>  
>  Function SocketPair(Domain,SocketType,Protocol:Longint;var Pair:TSockArray):Longint;
>  begin
> -  SocketPair:=fpsocketpair(domain,sockettype,protocol, at pair);
> +  SocketPair:=fpsocketpair(domain,sockettype,protocol, at pair[1]);
>  end;
>  
>  { mimic the linux fpWrite/fpRead calls for the file/text socket wrapper }
> Index: wince/dos.pp
> ===================================================================
> --- wince/dos.pp	(revision 5038)
> +++ wince/dos.pp	(working copy)
> @@ -256,7 +256,7 @@
>        repeat
>          if fd.dwFileAttributes and dev_attr = dev_attr then begin
>            len:=0;
> -          while fd.cFileName[len] <> 0 do
> +          while fd.cFileName[len] <> #0 do
>              Inc(len);
>            len:=(len + 2)*SizeOf(WideChar);
>            GetMem(DriveNames[i], len);
> Index: wince/sysutils.pp
> ===================================================================
> --- wince/sysutils.pp	(revision 5038)
> +++ wince/sysutils.pp	(working copy)
> @@ -290,7 +290,7 @@
>    WinToDosTime(F.FindData.ftLastWriteTime,F.Time);
>    f.size:=F.FindData.NFileSizeLow;
>    f.attr:=F.FindData.dwFileAttributes;
> -  PWideCharToString(@F.FindData.cFileName, f.Name);
> +  PWideCharToString(@F.FindData.cFileName[0], f.Name);
>    Result:=0;
>  end;
>  
> @@ -631,7 +631,7 @@
>           nil,
>           ErrorCode,
>           0,
> -         @MsgBuffer,                 { This function allocs the memory }
> +         PWideChar(@MsgBuffer),    { This function allocs the memory (in this case you pass a PPwidechar)}
>           0,
>           nil);
>    while (len > 0) and (MsgBuffer[len - 1] <= #32) do
> @@ -737,7 +737,7 @@
>    WinCEMajorVersion:=versionInfo.dwMajorVersion;
>    WinCEMinorVersion:=versionInfo.dwMinorVersion;
>    WinCEBuildNumber:=versionInfo.dwBuildNumber;
> -  i:=WideToAnsiBuf(@versioninfo.szCSDVersion, -1, @WinCECSDVersion[1], SizeOf(WinCECSDVersion) - 1);
> +  i:=WideToAnsiBuf(@versioninfo.szCSDVersion[0], -1, @WinCECSDVersion[1], SizeOf(WinCECSDVersion) - 1);
>    if i <> 0 then
>      WinCECSDVersion[0]:=chr(i - 1);
>  end;
> Index: win/wininc/base.inc
> ===================================================================
> --- win/wininc/base.inc	(revision 5038)
> +++ win/wininc/base.inc	(working copy)
> @@ -243,7 +243,7 @@
>  
>  {$ifdef UNICODE}
>       TBYTE = word;
> -     TCHAR = word;
> +     TCHAR = widechar;
>       BCHAR = word;
>  {$else}
>       TBYTE = byte;
> @@ -252,7 +252,7 @@
>  {$endif}
>  
>       UCHAR = byte;
> -     WCHAR = WideChar;
> +//     WCHAR = WideChar;
>  
>       UINT   = cardinal;
>       ULONG  = cardinal;
>   
> ------------------------------------------------------------------------
>
> _______________________________________________
> fpc-devel maillist  -  fpc-devel at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-devel
>   

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20061030/2f12a985/attachment.html>


More information about the fpc-devel mailing list