Windows 95 is not supported by Free Pascal 2.6.0 compiler

The 2.6.0 sources were supposed to be usable with Windows 95 if the RTL was compiled with -dSUPPORT_WIN95 compiler option added. But the Free Pascal Compiler development team has discovered after 2.6.0 release that the Free Pascal Compiler sources can not be used for Windows 95 Operating System without modifying shlightly the sources (using -dSUPPORT_WIN95 on unpatched sources results in a compilation error, hidden in the special code supporting Win95). This fix is not included in 2.6.0 sources.

The following patch allows to fix the 2.6.0 RTL sources in such a way as to be able to run applications compiled with that patched RTL on Windows 95 operating system.

Win95 version 2.6.0 RTL patch support

--- sysos.inc.orig	2012-01-03 11:20:40.000000000 +0100
+++ sysos.inc	2012-01-03 11:22:40.000000000 +0100
@@ -211,13 +211,24 @@
 
   function Win32GetCurrentThreadId:DWORD;
     stdcall; external KernelDLL name 'GetCurrentThreadId';
-{$endif WINCE}
 
-   { module functions }
-   function GetModuleFileName(l1:longint;p:pointer;l2:longint):longint;
-     {$ifdef wince}cdecl{$else}stdcall{$endif};external KernelDLL name 'GetModuleFileName' + ApiSuffix;
-   function GetModuleHandle(p : pchar) : PtrUInt;
-     {$ifdef wince}cdecl{$else}stdcall{$endif};external KernelDLL name 'GetModuleHandle' + ApiSuffix;
+  { module functions }
+  function GetModuleFileName(l1:THandle;p:PChar;l2:longint):longint;
+    stdcall;external KernelDLL name 'GetModuleFileNameA';
+
+  function GetModuleHandle(p : PChar) : THandle;
+    stdcall;external KernelDLL name 'GetModuleHandleA';
+
+{$else WINCE}
+ 
+    { module functions }
+   function GetModuleFileName(l1:THandle;p:PWideChar;l2:longint):longint;
+     cdecl;external KernelDLL name 'GetModuleFileNameW';
+ 
+   function GetModuleHandle(p : PWideChar) : THandle;
+     cdecl;external KernelDLL name 'GetModuleHandleW';
+
+{$endif WINCE}
 
    { file functions }
    function WriteFile(fh:thandle;buf:pointer;len:longint;var loaded:longint;

How to apply this patch?

You first need to install the sources of 2.6.0 RTL. After, just copy the content of the patch above to a file, named sysos.patch. Copy that file into the directory rtl/win, and apply the patch using:

patch -p 0 -i sysos.patch
Move back to rtl directory level, and recompile the RTL, using make:
make clean all OPT=-dSUPPORT_WIN95
If you want to be able to compile applications that should run on Windows 95 operating system, you should probably install the new rtl over the existing one.

If you try to recompile all the packages, you might also run into the cdrom directory problem: cdrom is a device name (like aux, con, lpt1, com1 ...) under standard Win95 installation, and thus no directory have this name is allowed. This means that on extraction of cdrom directory from fpcbuild-2.6.0.zip will fail, leading later to an error if you try to recompile the packages. To overcome this limitation, remove the occurences of cdrom inside makefile.fpc in packages directory and run:

fpcmake -Tall
in the same directory. After this change, the compilation of packages directory should succeed.

Pierre Muller, 2012-01-03