The African Chief wrote:
I had a problem with it in TESTMEM.PAS in the new bpcompat. However, I have since discovered that the problem lies in mixing the use of "ExitProc", and "AddExitProc" in the same program. Use one or the other, and the problem disappears. Use both == infinite loop.
I see. AddExitProc is the C function atexit which I don't know much about. However, I like the simple way of adding an exit proc (rather than messing with pointer as in BP's ExitProc), so I wrote a replacement for AddExitProc in pure Pascal which is quite possible. It's included below, it can be used as a separate unit or merged into the existing units. A demo programs follows.
BTW: Rather than an EP procedural parameter (as in sysutils.pas) I use a BP procedural type. One difference is that for a procedural parameter, a local procedure could be passed, which is unwanted here (since a local procedure would rely on its outer procedures to be active which is not the case during the finalization).
unit aep;
interface
type TProc = procedure;
procedure AddExitProc (Proc: TProc);
implementation
type PProcList = ^TProcList; TProcList = record Next: PProcList; Proc: TProc end;
var ProcList: PProcList = nil;
procedure AddExitProc (Proc: TProc); var Temp: PProcList; begin Temp := ProcList; New (ProcList); ProcList^.Next := Temp; ProcList^.Proc := Proc end;
to end do while ProcList<>nil do begin {$W-}var Temp: PProcList;{$W+} Temp := ProcList; ProcList := ProcList^.Next; Temp^.Proc; Dispose (Temp) end;
end.
program x; uses aep;
procedure world; begin writeln('world!') end;
procedure hello; begin write('Hello ') end;
begin AddExitProc(world); AddExitProc(hello) end.
Assign is built-in now, so you can remove it from system.pas.
Actually, the CygWin32 version still does not have it
Strange. Actually, the built-in Assign in the RTS (rts/rts-assign.p) is written in Pascal in just the same way as in system.pas, so I think it should compile on any platform. Is this just an omission, or are there any hidden problems? Or is the CygWin version an older binary distribution? Peter, Jan-Jaap?
Frank Heckenbach wrote:
The African Chief wrote:
I had a problem with it in TESTMEM.PAS in the new bpcompat. However, I have since discovered that the problem lies in mixing the use of "ExitProc", and "AddExitProc" in the same program. Use one or the other, and the problem disappears. Use both == infinite loop.
I see. AddExitProc is the C function atexit which I don't know much about. However, I like the simple way of adding an exit proc (rather than messing with pointer as in BP's ExitProc), so I wrote a replacement for AddExitProc in pure Pascal which is quite possible. It's included below, it can be used as a separate unit or merged into the existing units. A demo programs follows.
Ok - thanks. BTW: AddExitProc is for Delphi compatibility only.
Assign is built-in now, so you can remove it from system.pas.
Actually, the CygWin32 version still does not have it
Strange. Actually, the built-in Assign in the RTS (rts/rts-assign.p) is written in Pascal in just the same way as in system.pas, so I think it should compile on any platform. Is this just an omission, or are there any hidden problems? Or is the CygWin version an older binary distribution?
Yes, it is. I am not sure if Jan Jaap is still developing the Cygwin version anymore, since he seems to be working on an alternative version (mingw32) that does not require the Cygwin DLL.
Best regards, The Chief -------- Dr. Abimbola A. Olowofoyeku (The African Chief) Email: laa12@keele.ac.uk Author of: Chief's Installer Pro 4.01 for Win16 and Win32: Winner of PC PLUS Magazine Gold Award (April 1995 U.K. edition) http://ourworld.compuserve.com/homepages/African_Chief/
ftp://ftp.demon.co.uk/pub/ibmpc/win3/apps/chief/pro/chief401.zip