Fix compilation of WinCE. Change the fixed UNICODE define of WinCE to FPC_OS_UNICODE, so that it won't be undefined when changing the mode/string type and that the usage of a UNICODE API is independant of the mode.

Also adjusted all Windows (Win32/64/CE) units to define a "UNICODE" if "FPC_OS_UNICODE" is defined (except the Jedi units).
Also the common RTL units that checked for UNICODE now check for FPC_OS_UNICODE.

git-svn-id: trunk@24420 -
This commit is contained in:
svenbarth 2013-05-04 11:06:32 +00:00
parent 1de40c8de7
commit 930b76e8fb
28 changed files with 95 additions and 19 deletions

View File

@ -42,7 +42,7 @@ unit i_nativent;
tf_dwarf_only_local_labels]; tf_dwarf_only_local_labels];
cpu : cpu_i386; cpu : cpu_i386;
unit_env : 'NTUNITS'; unit_env : 'NTUNITS';
extradefines : 'NATIVENT,UNICODE'; extradefines : 'NATIVENT,FPC_OS_UNICODE';
exeext : '.exe'; exeext : '.exe';
defext : '.def'; defext : '.def';
scriptext : '.bat'; scriptext : '.bat';

View File

@ -174,7 +174,7 @@ unit i_win;
tf_safecall_exceptions,tf_no_backquote_support]; tf_safecall_exceptions,tf_no_backquote_support];
cpu : cpu_arm; cpu : cpu_arm;
unit_env : ''; unit_env : '';
extradefines : 'UNDER_CE;WINDOWS;UNICODE'; extradefines : 'UNDER_CE;WINDOWS;FPC_OS_UNICODE';
exeext : '.exe'; exeext : '.exe';
defext : '.def'; defext : '.def';
scriptext : '.bat'; scriptext : '.bat';
@ -239,7 +239,7 @@ unit i_win;
tf_safecall_exceptions,tf_no_backquote_support]; tf_safecall_exceptions,tf_no_backquote_support];
cpu : cpu_i386; cpu : cpu_i386;
unit_env : ''; unit_env : '';
extradefines : 'UNDER_CE;WINDOWS;UNICODE'; extradefines : 'UNDER_CE;WINDOWS;FPC_OS_UNICODE';
exeext : '.exe'; exeext : '.exe';
defext : '.def'; defext : '.def';
scriptext : '.bat'; scriptext : '.bat';

View File

@ -202,7 +202,7 @@ var
Stream: TResourceStream; Stream: TResourceStream;
begin begin
FreeResources; FreeResources;
Stream := TResourceStream.CreateFromID(Instance, 1, {$ifdef UNICODE}PWideChar{$else}PChar{$endif}(RT_VERSION)); Stream := TResourceStream.CreateFromID(Instance, 1, {$ifdef FPC_OS_UNICODE}PWideChar{$else}PChar{$endif}(RT_VERSION));
try try
FVersionInfo:=TVersionResource.Create; FVersionInfo:=TVersionResource.Create;
FVersionInfo.SetCustomRawDataStream(Stream); FVersionInfo.SetCustomRawDataStream(Stream);

View File

@ -83,6 +83,9 @@ interface
// ======== Define options for TRegExpr engine // ======== Define options for TRegExpr engine
{.$DEFINE UniCode} // Unicode support {.$DEFINE UniCode} // Unicode support
{$ifdef FPC_OS_UNICODE}
{$define UNICODE}
{$endif}
{$DEFINE RegExpPCodeDump} // p-code dumping (see Dump method) {$DEFINE RegExpPCodeDump} // p-code dumping (see Dump method)
{$IFNDEF FPC} // the option is not supported in FreePascal {$IFNDEF FPC} // the option is not supported in FreePascal
{$DEFINE reRealExceptionAddr} // exceptions will point to appropriate source line, not to Error procedure {$DEFINE reRealExceptionAddr} // exceptions will point to appropriate source line, not to Error procedure

View File

@ -52,6 +52,10 @@
unit cpl; unit cpl;
{$ifdef FPC_OS_UNICODE}
{$define UNICODE}
{$endif}
interface interface
uses Windows; uses Windows;
@ -244,4 +248,4 @@ const
implementation implementation
end. end.

View File

@ -25,6 +25,10 @@ unit imm;
{$CALLING cdecl} {$CALLING cdecl}
{$ifdef FPC_OS_UNICODE}
{$define UNICODE}
{$endif}
interface interface
uses Windows; uses Windows;
@ -1381,4 +1385,4 @@ function ImmGetKeyboardLayout(dwThreadId:DWORD):HKL; external ImmDLL name 'ImmGe
implementation implementation
end. end.

View File

@ -32,6 +32,10 @@ unit mmsystem;
{$CALLING cdecl} {$CALLING cdecl}
{$ifdef FPC_OS_UNICODE}
{$define UNICODE}
{$endif}
interface interface
uses Windows, mmreg; uses Windows, mmreg;

View File

@ -34,6 +34,10 @@ unit wininet;
{$CALLING cdecl} {$CALLING cdecl}
{$ifdef FPC_OS_UNICODE}
{$define UNICODE}
{$endif}
interface interface
uses Windows; uses Windows;

View File

@ -43,6 +43,10 @@ Unit CommCtrl;
Interface Interface
{$Mode ObjFPC} {$Mode ObjFPC}
{$ifdef FPC_OS_UNICODE}
{$define UNICODE}
{$endif}
Uses Windows,CTypes,ActiveX; Uses Windows,CTypes,ActiveX;
// -------------------- // --------------------

View File

@ -20,6 +20,10 @@ interface
{$ifndef Win64} {$ifndef Win64}
{$packrecords 1} {$packrecords 1}
{$endif} {$endif}
{$ifdef FPC_OS_UNICODE}
{$define UNICODE}
{$endif}
uses windows; uses windows;
Type Type

View File

@ -29,6 +29,10 @@ Uses Windows;
{$define imagehlp64} {$define imagehlp64}
{$endif} {$endif}
{$ifdef FPC_OS_UNICODE}
{$define UNICODE}
{$endif}
Const Const
IMAGE_SEPARATION = 64*1024; IMAGE_SEPARATION = 64*1024;
DBHHEADER_DEBUGDIRS = $1; DBHHEADER_DEBUGDIRS = $1;
@ -1599,4 +1603,4 @@ begin
p64^.SystemRangeStart := p32^.SystemRangeStart; p64^.SystemRangeStart := p32^.SystemRangeStart;
end; end;
end. end.

View File

@ -19,6 +19,10 @@ uses
{$PACKRECORDS C} {$PACKRECORDS C}
{$ifdef FPC_OS_UNICODE}
{$define UNICODE}
{$endif}
// IME_Codes // IME_Codes
// bit field for conversion mode // bit field for conversion mode
const const

View File

@ -11,6 +11,10 @@ Unit mmsystem;
{$smartlink on} {$smartlink on}
{$endif} {$endif}
{$MODE DELPHI} {$MODE DELPHI}
{$ifdef FPC_OS_UNICODE}
{$define UNICODE}
{$endif}
interface interface
uses uses
windows; windows;

View File

@ -30,6 +30,10 @@ unit MultiMon;
{$mode objfpc}{$H+} {$mode objfpc}{$H+}
{$ifdef FPC_OS_UNICODE}
{$define UNICODE}
{$endif}
interface interface
uses uses

View File

@ -4,6 +4,10 @@ unit richedit;
{$mode objfpc} {$mode objfpc}
{$calling stdcall} {$calling stdcall}
{$ifdef FPC_OS_UNICODE}
{$define UNICODE}
{$endif}
interface interface
uses Messages, Windows; uses Messages, Windows;

View File

@ -22,6 +22,10 @@
{$calling stdcall} {$calling stdcall}
{$mode objfpc} {$mode objfpc}
{$ifdef FPC_OS_UNICODE}
{$define UNICODE}
{$endif}
Unit ShellApi; Unit ShellApi;
//+------------------------------------------------------------------------- //+-------------------------------------------------------------------------

View File

@ -16,6 +16,10 @@ unit wininet;
{$smartlink on} {$smartlink on}
{$endif} {$endif}
{$ifdef FPC_OS_UNICODE}
{$define UNICODE}
{$endif}
interface interface
Uses Windows; Uses Windows;
@ -2774,4 +2778,4 @@ implementation
result:=(gtype and GOPHER_TYPE_GOPHER_PLUS)=0; result:=(gtype and GOPHER_TYPE_GOPHER_PLUS)=0;
end; end;
end. end.

View File

@ -8,7 +8,7 @@ type
TFPResourceHandle = PtrUInt; TFPResourceHandle = PtrUInt;
TFPResourceHMODULE = PtrUInt; TFPResourceHMODULE = PtrUInt;
TFPResourceHGLOBAL = PtrUInt; TFPResourceHGLOBAL = PtrUInt;
{$ifdef UNICODE} {$ifdef FPC_OS_UNICODE}
{roozbeh : maybe it shoud be moved after ifndef mswindows,as there is one declared in wince,base.inc} {roozbeh : maybe it shoud be moved after ifndef mswindows,as there is one declared in wince,base.inc}
MAKEINTRESOURCE = pwidechar; MAKEINTRESOURCE = pwidechar;
{$else} {$else}

View File

@ -998,7 +998,7 @@ type
{ TResourceStream } { TResourceStream }
{$ifdef UNICODE} {$ifdef FPC_OS_UNICODE}
TResourceStream = class(TCustomMemoryStream) TResourceStream = class(TCustomMemoryStream)
private private
Res: TFPResourceHandle; Res: TFPResourceHandle;
@ -1020,7 +1020,7 @@ type
constructor CreateFromID(Instance: TFPResourceHMODULE; ResID: Integer; ResType: PChar); constructor CreateFromID(Instance: TFPResourceHMODULE; ResID: Integer; ResType: PChar);
destructor Destroy; override; destructor Destroy; override;
end; end;
{$endif UNICODE} {$endif FPC_OS_UNICODE}
{ TStreamAdapter } { TStreamAdapter }

View File

@ -872,7 +872,7 @@ end;
{* TResourceStream *} {* TResourceStream *}
{****************************************************************************} {****************************************************************************}
{$ifdef UNICODE} {$ifdef FPC_OS_UNICODE}
procedure TResourceStream.Initialize(Instance: TFPResourceHMODULE; Name, ResType: PWideChar; NameIsID: Boolean); procedure TResourceStream.Initialize(Instance: TFPResourceHMODULE; Name, ResType: PWideChar; NameIsID: Boolean);
begin begin
Res:=FindResource(Instance, Name, ResType); Res:=FindResource(Instance, Name, ResType);
@ -900,7 +900,7 @@ constructor TResourceStream.CreateFromID(Instance: TFPResourceHMODULE; ResID: In
inherited create; inherited create;
Initialize(Instance,PWideChar(ResID),ResType,True); Initialize(Instance,PWideChar(ResID),ResType,True);
end; end;
{$else UNICODE} {$else FPC_OS_UNICODE}
procedure TResourceStream.Initialize(Instance: TFPResourceHMODULE; Name, ResType: PChar; NameIsID: Boolean); procedure TResourceStream.Initialize(Instance: TFPResourceHMODULE; Name, ResType: PChar; NameIsID: Boolean);
begin begin
@ -929,7 +929,7 @@ constructor TResourceStream.CreateFromID(Instance: TFPResourceHMODULE; ResID: In
inherited create; inherited create;
Initialize(Instance,pchar(PtrInt(ResID)),ResType,True); Initialize(Instance,pchar(PtrInt(ResID)),ResType,True);
end; end;
{$endif UNICODE} {$endif FPC_OS_UNICODE}
destructor TResourceStream.Destroy; destructor TResourceStream.Destroy;

View File

@ -120,15 +120,15 @@ type
UINT = cardinal; UINT = cardinal;
BOOL = longbool; BOOL = longbool;
// WCHAR = word; // WCHAR = word;
{$ifdef UNICODE} {$ifdef FPC_OS_UNICODE}
LPTCH = ^word; LPTCH = ^word;
LPTSTR = ^word; LPTSTR = ^word;
LPCTSTR = ^word; LPCTSTR = ^word;
{$else UNICODE} {$else FPC_OS_UNICODE}
LPTCH = ^char; LPTCH = ^char;
LPTSTR = ^char; LPTSTR = ^char;
LPCTSTR = ^char; LPCTSTR = ^char;
{$endif UNICODE} {$endif FPC_OS_UNICODE}
LPWSTR = ^wchar; LPWSTR = ^wchar;
PVOID = pointer; PVOID = pointer;
LPVOID = pointer; LPVOID = pointer;

View File

@ -14,6 +14,10 @@ unit WinSock2;
{$smartlink on} {$smartlink on}
{$endif} {$endif}
{$ifdef FPC_OS_UNICODE}
{$define UNICODE}
{$endif}
interface interface
Uses Windows; Uses Windows;

View File

@ -25,6 +25,10 @@ unit windows;
{$inline on} {$inline on}
{$calling stdcall} {$calling stdcall}
{$ifdef FPC_OS_UNICODE}
{$define UNICODE}
{$endif}
interface interface
{$define read_interface} {$define read_interface}

View File

@ -25,6 +25,10 @@ unit windows;
{$inline on} {$inline on}
{$calling stdcall} {$calling stdcall}
{$ifdef FPC_OS_UNICODE}
{$define UNICODE}
{$endif}
interface interface
{$define read_interface} {$define read_interface}

View File

@ -13,8 +13,6 @@
**********************************************************************} **********************************************************************}
{$define UNICODE} //ce is unicode only, needed here for classes.inc
{$mode objfpc} {$mode objfpc}
{ determine the type of the resource/form file } { determine the type of the resource/form file }

View File

@ -28,6 +28,10 @@ unit windows;
{ convention is cdecl for WinCE API} { convention is cdecl for WinCE API}
{$calling cdecl} {$calling cdecl}
{$ifdef FPC_OS_UNICODE}
{$define UNICODE}
{$endif}
interface interface

View File

@ -19,6 +19,9 @@ unit winsock;
{ convention is cdecl for WinCE API} { convention is cdecl for WinCE API}
{$calling cdecl} {$calling cdecl}
{$ifdef FPC_OS_UNICODE}
{$define UNICODE}
{$endif}
{remaining functions exported from ws2.dll and not used yet = to do, {remaining functions exported from ws2.dll and not used yet = to do,

View File

@ -18,6 +18,10 @@ unit WinSock2;
{ convention is cdecl for WinCE API} { convention is cdecl for WinCE API}
{$calling cdecl} {$calling cdecl}
{$ifdef FPC_OS_UNICODE}
{$define UNICODE}
{$endif}
interface interface
Uses Windows; Uses Windows;