[fpc-devel] Compiler directives in getopts unit

Michael Van Canneyt michael at freepascal.org
Fri Jan 18 00:06:53 CET 2019



On Thu, 17 Jan 2019, Bart wrote:

> Hi,
>
> I'm trying to fix an issue in getopts unit.
> I noticed some (ancient?) compiler directives:
>
> {$IFNDEF FPC}
>  {$ifdef TP}
>    uses strings;
>  {$else }
>    uses SysUtils;
>    type PtrInt = Integer;
>  {$endif}
> {$ENDIF FPC}
>
> {$IF not Declared(argv)} //{$ifdef TP}
> type
>  ppchar = ^pchar;
>  apchar = array[0..127] of pchar;
> var
>  argc  : longint;
>  argv  : apchar;
> ....
>
> { create argv if running under TP }
> {$ifndef FPC}
>  setup_arguments;
> {$endif}
>
>
> It seems this code at one time needed to be compilable with TP.
> AFAIK TP however does not support {$IF CONDITION} nor the Declared()
> macro(?), so the source should not be compilable anymore with TP?

Clearly not.

>
> The unit is still compileable with Delphi (7) though.
>
> Question is: do we need to keep that in?

No.

> I don't think it is possible anymore to bootstrap the compiler with
> anything other than FPC?

Exactly.

>
> As for the {$IF not Declared(Argv)} part: does that apply to a target
> that FPC supports or is also there just to be able to compile it with
> Delphi?
>
> If we keep it, then at least the comments should be updated.

You can make the unit FPC only if you wish.

Michael.



More information about the fpc-devel mailing list