Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2019-01

Compiler directives in getopts unit

7 messages · 5 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Bart

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?

The unit is still compileable with Delphi (7) though.

Question is: do we need to keep that in?
I don't think it is possible anymore to bootstrap the compiler with anything other than FPC?

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.

Bart

Bart

Reply by email

Unknown author
to Bart
Bart wrote
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?

if we set TP mode, what will happens if $IF is removed/changed?

i still have a lot of TP code here and some of it has been ported to FPC... some of that ported code has been recoded to use getopts which allow a lot of other code to be stripped out because getopts handles command line options much better...

NOTE: No off-list assistance is given without prior approval. *Please keep mailing list traffic on the list unless* *a signed and pre-paid contract is in effect with us.*

Reply by email

J. Gareth Moreton

At the very least, compiling under Turbo Pascal for historic reasons. Unless I'm mistaken, the very first versions of Free Pascal were written in Turbo Pascal 7.0 because Borland announced it would not make a compiler for 32-bit processors (having moved their focus to their little-known, upcoming Windows project known as Delphi).  Development under Turbo Pascal ceased once the compiler was able to compile itself.

Gareth aka. Kit

Bart wrote
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?

if we set TP mode, what will happens if $IF is removed/changed?

i still have a lot of TP code here and some of it has been ported to FPC... some
of that ported code has been recoded to use getopts which allow a lot of other
code to be stripped out because getopts handles command line options much better...

NOTE: No off-list assistance is given without prior approval. *Please keep mailing list traffic on the list unless* *a signed and pre-paid contract is in effect with us.*

Reply by email

Sven Barth
to Unknown author: if we set TP mode, what will happens if $IF is removed/changed? i still have a lot of TP…

Am 17.01.2019 um 20:29 schrieb

Show quoted text 11 lines
On 1/17/19 1:23 PM, Bart wrote: > 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? if we set TP mode, what will happens if $IF is removed/changed? i still have a lot of TP code here and some of it has been ported to FPC... some of that ported code has been recoded to use getopts which allow a lot of other code to be stripped out because getopts handles command line options much better...

Even if you set TP mode in your own unit that won't change the mode of the getopts unit. FPC can use units with different modes without any problems.

Also scanning condition expressions is nearly completely independant of the mode (one of the only exceptions is support for special MacPas directives in MacPas mode).

Regards,
Sven

Reply by email

Michael Van Canneyt
to Bart: I'm trying to fix an issue in getopts unit. I noticed some (ancient?) compiler directives:
Bart wrote 32 lines
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.

Show quoted text 6 lines
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.

Reply by email

Sven Barth
to Michael Van Canneyt
Michael Van Canneyt wrote 9 lines
> > 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.

I just checked the logs: the unit had been explicitely made Delphi compatible by adding the check for argv. So maybe we shouldn't just throw that one out of the window... (TP compatibility is a different topic)

Regards,
Sven

Reply by email

Michael Van Canneyt
to Sven Barth
Sven Barth wrote 13 lines
Am 18.01.2019 um 00:06 schrieb Michael Van Canneyt: > >> >> 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. I just checked the logs: the unit had been explicitely made Delphi compatible by adding the check for argv. So maybe we shouldn't just throw that one out of the window... (TP compatibility is a different topic)

If support for delphi can be reduced to an IFDEF FPC with the ELSE for Delphi (or vice versa) in one or 2 places I'm inclined to agree...
But if it needs much more than that I am not really in favour...

Michael.

Reply by email