[fpc-pascal] CrossPlatform problem, INFINITE not defined on Linux

Michael Van Canneyt michael at freepascal.org
Sun Jul 19 08:46:14 CEST 2020



On Sun, 19 Jul 2020, Bo Berglund via fpc-pascal wrote:

> I am porting an old application from Delphi to Lazarus and Windows to
> Linux.
> This application has a unit ExecWait, which was created to simplify
> running tool programs from the main program, so it supplies two
> procedures as:
>
> function ExecAndWait(Cmdline: string; Hide: boolean = false; MaxWait:
> DWORD = INFINITE; Prio: TExecPrio = normal): DWORD;
> function ExecStart(Cmdline: string; InheritHandle: boolean = true;
> Prio: TExecPrio = normal): DWORD;
>
> I have had no problems with this unit when moving from Delphi to FPC,
> it compiles just fine on Windows.
>
> But when I move the code to Linux (via Subversion) it throws an error
> on "Run/Quick Compile":
>
> ExecWait.pas(15,79) Error: Identifier not found "INFINITE"
>
> The line that gets the error is the declaration for ExecAndWait above.
>
> On Windows I could check where it is defined and I found it in:
> C:\Programs\Lazarus_2.0.8\fpc\3.0.4\source\rtl\win\wininc\defines.inc
>
> How do I bring in the corresponding Linux version of this?

You can't. INFINITE is specific to Windows.

You must get rid of the ExecAndWait. This is just the first error you will
run into, many more will follow.

The corresponding functions exist in FPC :

ExecuteProcess in SysUtils unit:
https://www.freepascal.org/docs-html/current/rtl/sysutils/executeprocess.html

Various RunCommand procedures in process unit:
https://www.freepascal.org/docs-html/current/fcl/process/runcommand.html

or use TProcess.
https://www.freepascal.org/docs-html/current/fcl/process/tprocess.html

Michael.


More information about the fpc-pascal mailing list