From 930b76e8fbf4ba82dbf4f11ea73cefd841476b04 Mon Sep 17 00:00:00 2001 From: svenbarth Date: Sat, 4 May 2013 11:06:32 +0000 Subject: [PATCH] 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 - --- compiler/systems/i_nativent.pas | 2 +- compiler/systems/i_win.pas | 4 ++-- packages/fcl-base/src/fileinfo.pp | 2 +- packages/regexpr/src/regexpr.pas | 3 +++ packages/winceunits/src/cpl.pp | 6 +++++- packages/winceunits/src/imm.pp | 6 +++++- packages/winceunits/src/mmsystem.pp | 4 ++++ packages/winceunits/src/wininet.pp | 4 ++++ packages/winunits-base/src/commctrl.pp | 4 ++++ packages/winunits-base/src/commdlg.pp | 4 ++++ packages/winunits-base/src/imagehlp.pp | 6 +++++- packages/winunits-base/src/imm.pas | 4 ++++ packages/winunits-base/src/mmsystem.pp | 4 ++++ packages/winunits-base/src/multimon.pp | 4 ++++ packages/winunits-base/src/richedit.pp | 4 ++++ packages/winunits-base/src/shellapi.pp | 4 ++++ packages/winunits-base/src/wininet.pp | 6 +++++- rtl/inc/resh.inc | 2 +- rtl/objpas/classes/classesh.inc | 4 ++-- rtl/objpas/classes/streams.inc | 6 +++--- rtl/win/sysos.inc | 6 +++--- rtl/win/winsock2.pp | 4 ++++ rtl/win32/windows.pp | 4 ++++ rtl/win64/windows.pp | 4 ++++ rtl/wince/classes.pp | 2 -- rtl/wince/windows.pp | 4 ++++ rtl/wince/winsock.pp | 3 +++ rtl/wince/winsock2.pp | 4 ++++ 28 files changed, 95 insertions(+), 19 deletions(-) diff --git a/compiler/systems/i_nativent.pas b/compiler/systems/i_nativent.pas index 9828a56611..cc70a9f409 100644 --- a/compiler/systems/i_nativent.pas +++ b/compiler/systems/i_nativent.pas @@ -42,7 +42,7 @@ unit i_nativent; tf_dwarf_only_local_labels]; cpu : cpu_i386; unit_env : 'NTUNITS'; - extradefines : 'NATIVENT,UNICODE'; + extradefines : 'NATIVENT,FPC_OS_UNICODE'; exeext : '.exe'; defext : '.def'; scriptext : '.bat'; diff --git a/compiler/systems/i_win.pas b/compiler/systems/i_win.pas index c995f07f3e..e7b32c8762 100644 --- a/compiler/systems/i_win.pas +++ b/compiler/systems/i_win.pas @@ -174,7 +174,7 @@ unit i_win; tf_safecall_exceptions,tf_no_backquote_support]; cpu : cpu_arm; unit_env : ''; - extradefines : 'UNDER_CE;WINDOWS;UNICODE'; + extradefines : 'UNDER_CE;WINDOWS;FPC_OS_UNICODE'; exeext : '.exe'; defext : '.def'; scriptext : '.bat'; @@ -239,7 +239,7 @@ unit i_win; tf_safecall_exceptions,tf_no_backquote_support]; cpu : cpu_i386; unit_env : ''; - extradefines : 'UNDER_CE;WINDOWS;UNICODE'; + extradefines : 'UNDER_CE;WINDOWS;FPC_OS_UNICODE'; exeext : '.exe'; defext : '.def'; scriptext : '.bat'; diff --git a/packages/fcl-base/src/fileinfo.pp b/packages/fcl-base/src/fileinfo.pp index e5e401dbb7..71939ee76c 100644 --- a/packages/fcl-base/src/fileinfo.pp +++ b/packages/fcl-base/src/fileinfo.pp @@ -202,7 +202,7 @@ var Stream: TResourceStream; begin 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 FVersionInfo:=TVersionResource.Create; FVersionInfo.SetCustomRawDataStream(Stream); diff --git a/packages/regexpr/src/regexpr.pas b/packages/regexpr/src/regexpr.pas index ed2aa17701..e267918248 100644 --- a/packages/regexpr/src/regexpr.pas +++ b/packages/regexpr/src/regexpr.pas @@ -83,6 +83,9 @@ interface // ======== Define options for TRegExpr engine {.$DEFINE UniCode} // Unicode support +{$ifdef FPC_OS_UNICODE} + {$define UNICODE} +{$endif} {$DEFINE RegExpPCodeDump} // p-code dumping (see Dump method) {$IFNDEF FPC} // the option is not supported in FreePascal {$DEFINE reRealExceptionAddr} // exceptions will point to appropriate source line, not to Error procedure diff --git a/packages/winceunits/src/cpl.pp b/packages/winceunits/src/cpl.pp index 773e48b839..8a6c9f3306 100644 --- a/packages/winceunits/src/cpl.pp +++ b/packages/winceunits/src/cpl.pp @@ -52,6 +52,10 @@ unit cpl; +{$ifdef FPC_OS_UNICODE} + {$define UNICODE} +{$endif} + interface uses Windows; @@ -244,4 +248,4 @@ const implementation -end. \ No newline at end of file +end. diff --git a/packages/winceunits/src/imm.pp b/packages/winceunits/src/imm.pp index 68f3b1237e..48f2c73377 100644 --- a/packages/winceunits/src/imm.pp +++ b/packages/winceunits/src/imm.pp @@ -25,6 +25,10 @@ unit imm; {$CALLING cdecl} +{$ifdef FPC_OS_UNICODE} + {$define UNICODE} +{$endif} + interface uses Windows; @@ -1381,4 +1385,4 @@ function ImmGetKeyboardLayout(dwThreadId:DWORD):HKL; external ImmDLL name 'ImmGe implementation -end. \ No newline at end of file +end. diff --git a/packages/winceunits/src/mmsystem.pp b/packages/winceunits/src/mmsystem.pp index ec49ff2135..55ebd972a7 100644 --- a/packages/winceunits/src/mmsystem.pp +++ b/packages/winceunits/src/mmsystem.pp @@ -32,6 +32,10 @@ unit mmsystem; {$CALLING cdecl} +{$ifdef FPC_OS_UNICODE} + {$define UNICODE} +{$endif} + interface uses Windows, mmreg; diff --git a/packages/winceunits/src/wininet.pp b/packages/winceunits/src/wininet.pp index 32268bb854..23710b988d 100644 --- a/packages/winceunits/src/wininet.pp +++ b/packages/winceunits/src/wininet.pp @@ -34,6 +34,10 @@ unit wininet; {$CALLING cdecl} +{$ifdef FPC_OS_UNICODE} + {$define UNICODE} +{$endif} + interface uses Windows; diff --git a/packages/winunits-base/src/commctrl.pp b/packages/winunits-base/src/commctrl.pp index 89a3a9bc4c..fc666b2b8f 100644 --- a/packages/winunits-base/src/commctrl.pp +++ b/packages/winunits-base/src/commctrl.pp @@ -43,6 +43,10 @@ Unit CommCtrl; Interface {$Mode ObjFPC} + +{$ifdef FPC_OS_UNICODE} + {$define UNICODE} +{$endif} Uses Windows,CTypes,ActiveX; // -------------------- diff --git a/packages/winunits-base/src/commdlg.pp b/packages/winunits-base/src/commdlg.pp index 6ff3859570..7a0785b868 100644 --- a/packages/winunits-base/src/commdlg.pp +++ b/packages/winunits-base/src/commdlg.pp @@ -20,6 +20,10 @@ interface {$ifndef Win64} {$packrecords 1} {$endif} + +{$ifdef FPC_OS_UNICODE} + {$define UNICODE} +{$endif} uses windows; Type diff --git a/packages/winunits-base/src/imagehlp.pp b/packages/winunits-base/src/imagehlp.pp index 238901f260..ed22024611 100644 --- a/packages/winunits-base/src/imagehlp.pp +++ b/packages/winunits-base/src/imagehlp.pp @@ -29,6 +29,10 @@ Uses Windows; {$define imagehlp64} {$endif} +{$ifdef FPC_OS_UNICODE} + {$define UNICODE} +{$endif} + Const IMAGE_SEPARATION = 64*1024; DBHHEADER_DEBUGDIRS = $1; @@ -1599,4 +1603,4 @@ begin p64^.SystemRangeStart := p32^.SystemRangeStart; end; -end. \ No newline at end of file +end. diff --git a/packages/winunits-base/src/imm.pas b/packages/winunits-base/src/imm.pas index 9f658e6e31..ba57e8046a 100644 --- a/packages/winunits-base/src/imm.pas +++ b/packages/winunits-base/src/imm.pas @@ -19,6 +19,10 @@ uses {$PACKRECORDS C} +{$ifdef FPC_OS_UNICODE} + {$define UNICODE} +{$endif} + // IME_Codes // bit field for conversion mode const diff --git a/packages/winunits-base/src/mmsystem.pp b/packages/winunits-base/src/mmsystem.pp index e3af94a948..d7c103199d 100644 --- a/packages/winunits-base/src/mmsystem.pp +++ b/packages/winunits-base/src/mmsystem.pp @@ -11,6 +11,10 @@ Unit mmsystem; {$smartlink on} {$endif} {$MODE DELPHI} + +{$ifdef FPC_OS_UNICODE} + {$define UNICODE} +{$endif} interface uses windows; diff --git a/packages/winunits-base/src/multimon.pp b/packages/winunits-base/src/multimon.pp index 6345281a7f..33e8cca4c4 100644 --- a/packages/winunits-base/src/multimon.pp +++ b/packages/winunits-base/src/multimon.pp @@ -30,6 +30,10 @@ unit MultiMon; {$mode objfpc}{$H+} +{$ifdef FPC_OS_UNICODE} + {$define UNICODE} +{$endif} + interface uses diff --git a/packages/winunits-base/src/richedit.pp b/packages/winunits-base/src/richedit.pp index e450884867..42c860f8b0 100644 --- a/packages/winunits-base/src/richedit.pp +++ b/packages/winunits-base/src/richedit.pp @@ -4,6 +4,10 @@ unit richedit; {$mode objfpc} {$calling stdcall} +{$ifdef FPC_OS_UNICODE} + {$define UNICODE} +{$endif} + interface uses Messages, Windows; diff --git a/packages/winunits-base/src/shellapi.pp b/packages/winunits-base/src/shellapi.pp index e4452b6689..2622b5ebb8 100644 --- a/packages/winunits-base/src/shellapi.pp +++ b/packages/winunits-base/src/shellapi.pp @@ -22,6 +22,10 @@ {$calling stdcall} {$mode objfpc} +{$ifdef FPC_OS_UNICODE} + {$define UNICODE} +{$endif} + Unit ShellApi; //+------------------------------------------------------------------------- diff --git a/packages/winunits-base/src/wininet.pp b/packages/winunits-base/src/wininet.pp index f9e9ca92de..6376d2df5d 100644 --- a/packages/winunits-base/src/wininet.pp +++ b/packages/winunits-base/src/wininet.pp @@ -16,6 +16,10 @@ unit wininet; {$smartlink on} {$endif} +{$ifdef FPC_OS_UNICODE} + {$define UNICODE} +{$endif} + interface Uses Windows; @@ -2774,4 +2778,4 @@ implementation result:=(gtype and GOPHER_TYPE_GOPHER_PLUS)=0; end; -end. \ No newline at end of file +end. diff --git a/rtl/inc/resh.inc b/rtl/inc/resh.inc index 22cf906765..f40690d085 100644 --- a/rtl/inc/resh.inc +++ b/rtl/inc/resh.inc @@ -8,7 +8,7 @@ type TFPResourceHandle = PtrUInt; TFPResourceHMODULE = 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} MAKEINTRESOURCE = pwidechar; {$else} diff --git a/rtl/objpas/classes/classesh.inc b/rtl/objpas/classes/classesh.inc index e0f7606a64..735d05d2d2 100644 --- a/rtl/objpas/classes/classesh.inc +++ b/rtl/objpas/classes/classesh.inc @@ -998,7 +998,7 @@ type { TResourceStream } -{$ifdef UNICODE} +{$ifdef FPC_OS_UNICODE} TResourceStream = class(TCustomMemoryStream) private Res: TFPResourceHandle; @@ -1020,7 +1020,7 @@ type constructor CreateFromID(Instance: TFPResourceHMODULE; ResID: Integer; ResType: PChar); destructor Destroy; override; end; -{$endif UNICODE} +{$endif FPC_OS_UNICODE} { TStreamAdapter } diff --git a/rtl/objpas/classes/streams.inc b/rtl/objpas/classes/streams.inc index c061f1a033..5030b34d99 100644 --- a/rtl/objpas/classes/streams.inc +++ b/rtl/objpas/classes/streams.inc @@ -872,7 +872,7 @@ end; {* TResourceStream *} {****************************************************************************} -{$ifdef UNICODE} +{$ifdef FPC_OS_UNICODE} procedure TResourceStream.Initialize(Instance: TFPResourceHMODULE; Name, ResType: PWideChar; NameIsID: Boolean); begin Res:=FindResource(Instance, Name, ResType); @@ -900,7 +900,7 @@ constructor TResourceStream.CreateFromID(Instance: TFPResourceHMODULE; ResID: In inherited create; Initialize(Instance,PWideChar(ResID),ResType,True); end; -{$else UNICODE} +{$else FPC_OS_UNICODE} procedure TResourceStream.Initialize(Instance: TFPResourceHMODULE; Name, ResType: PChar; NameIsID: Boolean); begin @@ -929,7 +929,7 @@ constructor TResourceStream.CreateFromID(Instance: TFPResourceHMODULE; ResID: In inherited create; Initialize(Instance,pchar(PtrInt(ResID)),ResType,True); end; -{$endif UNICODE} +{$endif FPC_OS_UNICODE} destructor TResourceStream.Destroy; diff --git a/rtl/win/sysos.inc b/rtl/win/sysos.inc index 2c5068a7f9..14ba71a560 100644 --- a/rtl/win/sysos.inc +++ b/rtl/win/sysos.inc @@ -120,15 +120,15 @@ type UINT = cardinal; BOOL = longbool; // WCHAR = word; -{$ifdef UNICODE} +{$ifdef FPC_OS_UNICODE} LPTCH = ^word; LPTSTR = ^word; LPCTSTR = ^word; -{$else UNICODE} +{$else FPC_OS_UNICODE} LPTCH = ^char; LPTSTR = ^char; LPCTSTR = ^char; -{$endif UNICODE} +{$endif FPC_OS_UNICODE} LPWSTR = ^wchar; PVOID = pointer; LPVOID = pointer; diff --git a/rtl/win/winsock2.pp b/rtl/win/winsock2.pp index 63c9778683..48d3342ccf 100644 --- a/rtl/win/winsock2.pp +++ b/rtl/win/winsock2.pp @@ -14,6 +14,10 @@ unit WinSock2; {$smartlink on} {$endif} +{$ifdef FPC_OS_UNICODE} + {$define UNICODE} +{$endif} + interface Uses Windows; diff --git a/rtl/win32/windows.pp b/rtl/win32/windows.pp index 716430c1b4..af1dc37b77 100644 --- a/rtl/win32/windows.pp +++ b/rtl/win32/windows.pp @@ -25,6 +25,10 @@ unit windows; {$inline on} {$calling stdcall} +{$ifdef FPC_OS_UNICODE} + {$define UNICODE} +{$endif} + interface {$define read_interface} diff --git a/rtl/win64/windows.pp b/rtl/win64/windows.pp index f43743190d..e19e955124 100644 --- a/rtl/win64/windows.pp +++ b/rtl/win64/windows.pp @@ -25,6 +25,10 @@ unit windows; {$inline on} {$calling stdcall} +{$ifdef FPC_OS_UNICODE} + {$define UNICODE} +{$endif} + interface {$define read_interface} diff --git a/rtl/wince/classes.pp b/rtl/wince/classes.pp index c05fe51576..6fe7d7e2c1 100644 --- a/rtl/wince/classes.pp +++ b/rtl/wince/classes.pp @@ -13,8 +13,6 @@ **********************************************************************} -{$define UNICODE} //ce is unicode only, needed here for classes.inc - {$mode objfpc} { determine the type of the resource/form file } diff --git a/rtl/wince/windows.pp b/rtl/wince/windows.pp index 541c9885b3..22241a545d 100644 --- a/rtl/wince/windows.pp +++ b/rtl/wince/windows.pp @@ -28,6 +28,10 @@ unit windows; { convention is cdecl for WinCE API} {$calling cdecl} +{$ifdef FPC_OS_UNICODE} + {$define UNICODE} +{$endif} + interface diff --git a/rtl/wince/winsock.pp b/rtl/wince/winsock.pp index 88275d2e25..2516a3f807 100644 --- a/rtl/wince/winsock.pp +++ b/rtl/wince/winsock.pp @@ -19,6 +19,9 @@ unit winsock; { convention is cdecl for WinCE API} {$calling cdecl} +{$ifdef FPC_OS_UNICODE} + {$define UNICODE} +{$endif} {remaining functions exported from ws2.dll and not used yet = to do, diff --git a/rtl/wince/winsock2.pp b/rtl/wince/winsock2.pp index 60a7272879..5a5e708bc1 100644 --- a/rtl/wince/winsock2.pp +++ b/rtl/wince/winsock2.pp @@ -18,6 +18,10 @@ unit WinSock2; { convention is cdecl for WinCE API} {$calling cdecl} +{$ifdef FPC_OS_UNICODE} + {$define UNICODE} +{$endif} + interface Uses Windows;