Sign in Join

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

Mailing lists / fpc-devel / 2006-08

$IF issues

10 messages · 6 people ·

Reply by email Subscribe to this list Your subscription

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

Graeme Geldenhuys

Looking at the code below...

{$if defined(ver2_0)}
  {$note This is not delphi compatible. }
{$endif}

Is this a feature or a FPC bug? FPC allows the $IF to be closed with the $ENDIF as well as the $IFEND. This is not Delphi compatible.

The closing tag for $IF is $IFEND
The closing tag for $IFDEF is $ENDIF

Regards,
- Graeme -

There's no place like 127.0.0.1

Reply by email

Peter Vreman
to Graeme Geldenhuys
Show quoted text 12 lines
Looking at the code below... {$if defined(ver2_0)} {$note This is not delphi compatible. } {$endif} Is this a feature or a FPC bug? FPC allows the $IF to be closed with the $ENDIF as well as the $IFEND. This is not Delphi compatible. The closing tag for $IF is $IFEND The closing tag for $IFDEF is $ENDIF

Feature.

Reply by email

Graeme Geldenhuys
to Peter Vreman
Peter Vreman wrote 7 lines
> Is this a feature or a FPC bug? FPC allows the $IF to be closed with > the $ENDIF as well as the $IFEND. This is not Delphi compatible. > > The closing tag for $IF is $IFEND > The closing tag for $IFDEF is $ENDIF Feature.

Maybe this should be controlled by the compiler mode? Delphi vs ObjFPC. Or should we leave it up to the developer to remember which one to use when writing code to be compiled with Delphi and FPC?

Regards,
- Graeme -

There's no place like 127.0.0.1

Reply by email

Daniël Mantione
to Graeme Geldenhuys

Op Mon, 14 Aug 2006, schreef Graeme Geldenhuys:

Show quoted text 7 lines
On 8/14/06, Peter Vreman wrote: > > Is this a feature or a FPC bug? FPC allows the $IF to be closed > > with > > the $ENDIF as well as the $IFEND. This is not Delphi compatible. > > > > The closing tag for $IF is $IFEND > > The closing tag for $IFDEF is $ENDIF

As I read it, $IF/$IFEND was added to Delphi in Delphi 6. FPC supports this construction much longer, I think since the 0.9.x series. The FPC way has always been to use $ENDIF and FPC will of course not break compatibility with itself. Go ask Borland why they wanted to be FPC incompatible :)

Show quoted text 6 lines
> > Feature. Maybe this should be controlled by the compiler mode? Delphi vs ObjFPC. Or should we leave it up to the developer to remember which one to use when writing code to be compiled with Delphi and FPC?

You could make it dependent on the compiler mode, but I don't see the point, any Delphi code will still compile.

Daniël

Reply by email

Vincent Snijders
to Daniël Mantione
Daniël Mantione wrote 25 lines
Op Mon, 14 Aug 2006, schreef Graeme Geldenhuys: > On 8/14/06, Peter Vreman wrote: >>> Is this a feature or a FPC bug? FPC allows the $IF to be closed >>> with >>> the $ENDIF as well as the $IFEND. This is not Delphi compatible. >>> >>> The closing tag for $IF is $IFEND >>> The closing tag for $IFDEF is $ENDIF As I read it, $IF/$IFEND was added to Delphi in Delphi 6. FPC supports this construction much longer, I think since the 0.9.x series. The FPC way has always been to use $ENDIF and FPC will of course not break compatibility with itself. Go ask Borland why they wanted to be FPC incompatible :) >> Feature. > Maybe this should be controlled by the compiler mode? Delphi vs > ObjFPC. Or should we leave it up to the developer to remember which > one to use when writing code to be compiled with Delphi and FPC? You could make it dependent on the compiler mode, but I don't see the point, any Delphi code will still compile.

You miss the point: Delphi compatibility mode is for people who develop for FPC, but want to compile occasionally in Delphi. In the current situation they are not aware of this weakness of Delphi (no support of $ENDIF for $IF), until they compile in Delphi. But maybe Graeme should make a Delphi feature request too (and see which is honoured first) :-)

Vincent

Reply by email

Graeme Geldenhuys
to Vincent Snijders
Vincent Snijders wrote
You miss the point: Delphi compatibility mode is for people who develop for FPC, but want to compile occasionally in Delphi. In the current situation they are not aware of this weakness of Delphi (no support of $ENDIF for $IF), until they compile in Delphi.

That is exactly what happened. I only develop under FPC, but contribute a lot to the tiOPF project, which is mostly used by Delphi developers. I broke the Delphi builds by adding the $IF..$ENDIF code. The tiOPF project uses the Delphi Mode for the FPC compiler, and I was surprised when notified of the problem.

But maybe Graeme should make a Delphi feature request too (and see which is honoured first) :-)

Where do I go, to ask for such a feature in Borland Delphi? I guess it would take years to materialize. :-) Borland is not as pro-active as the FPC maintainers!!

Regards,
Graeme.

There's no place like 127.0.0.1

Reply by email

Daniël Mantione
to Vincent Snijders: You miss the point: Delphi compatibility mode is for people who develop for FPC, but want…

Op Mon, 14 Aug 2006, schreef Vincent Snijders:

You miss the point: Delphi compatibility mode is for people who develop for FPC, but want to compile occasionally in Delphi.

It can be used that way, but its main purpose is to support Delphi constructions that we consider broken and therefore do not want in objpas mode. To write new code that is compilable by both FPC and Delphi, Objpas mode should suit as well as Delphi mode.

In the current situation they are not aware of this weakness of Delphi (no support of $ENDIF for $IF), until they compile in Delphi. But maybe Graeme should make a Delphi feature request too (and see which is honoured first) :-)

In all modes a significant portion of FPC functionality is still enabled; the modes not designed with this goal in mind. It will always be possible to write code in FPC that Delphi doesn't accept; for example there exists no sane way you can prevent people from using FPC specific features in the RTL.

Daniël

Reply by email

Michael Van Canneyt
to Daniël Mantione
Daniël Mantione wrote 11 lines
Op Mon, 14 Aug 2006, schreef Vincent Snijders: > You miss the point: Delphi compatibility mode is for people who develop for > FPC, but want to compile occasionally in Delphi. It can be used that way, but its main purpose is to support Delphi constructions that we consider broken and therefore do not want in objpas mode. To write new code that is compilable by both FPC and Delphi, Objpas mode should suit as well as Delphi mode.

This is not quite correct: Think of e.g. the @Method issue.

And the Delphi/TP modes are designed to be as Delphi/TP compatible as possible.

Michael.

Reply by email

Graeme Geldenhuys
to Daniël Mantione: Op Mon, 14 Aug 2006, schreef Vincent Snijders: It can be used that way, but its main…
Daniël Mantione wrote
mode. To write new code that is compilable by both FPC and Delphi, Objpas mode should suit as well as Delphi mode.

Not quite! The project I am working on (tiOPF) is mainly used by Delphi developers, as I mentioned before. My first thought was to use tiOPF with FPC in compiler mode ObjFPC. I had to add over a hundred IFDEF's for all the @ProcedureName assignments. A few months later, the Delphi delevelopers got sick of all the IFDEF's in the code. I changed the FPC compiler mode to Delphi and could remove all those IFDEF's with the @ sign. That is just one such difference in the compiler modes.

Regards,
- Graeme -

There's no place like 127.0.0.1

Reply by email

Florian Klaempfl
to Graeme Geldenhuys: That is exactly what happened. I only develop under FPC, but contribute a lot to the…
Graeme Geldenhuys wrote 14 lines
On 8/14/06, Vincent Snijders wrote: > You miss the point: Delphi compatibility mode is for people who > develop for FPC, but > want to compile occasionally in Delphi. In the current situation they > are not aware > of this weakness of Delphi (no support of $ENDIF for $IF), until they > compile in > Delphi. That is exactly what happened. I only develop under FPC, but contribute a lot to the tiOPF project, which is mostly used by Delphi developers. I broke the Delphi builds by adding the $IF..$ENDIF code. The tiOPF project uses the Delphi Mode for the FPC compiler, and I was surprised when notified of the problem.

Well, the delphi mode is made to compile delphi programs with fpc not to check your programs for delphi compliance ;)

Show quoted text 13 lines
> But maybe Graeme should make a Delphi feature request too (and see > which is > honoured first) :-) Where do I go, to ask for such a feature in Borland Delphi? I guess it would take years to materialize. :-) Borland is not as pro-active as the FPC maintainers!! Regards, Graeme.

Reply by email