Unexpected duplicate identifiers

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Unexpected duplicate identifiers

Mark Morgan Lloyd-5
I've got a class that looks in part like this:

TTextStore= CLASS(TStringList)
             PRIVATE
               PROCEDURE NeverSort(sort: BOOLEAN);
             PUBLIC
               FUNCTION HereDocument(CONST name: STRING; VAR strings:
TStringList): BOOLEAN;
               PROCEDURE Sort; OVERRIDE;

FPC 2.2.0 is giving me duplicate identifier errors for "sort" and
"strings" above.

I've got nothing against going through the comparatively small amount of
code affected but I'm a little mystified as to why this is happening:
the rather elderly version of Delphi I'm using doesn't object, and I
don't see why there should be a conflict between the class procedure and
procedure parameter names.

--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Unexpected duplicate identifiers

Darius Blaszyk
> I've got a class that looks in part like this:
>
> TTextStore= CLASS(TStringList)
>              PRIVATE
>                PROCEDURE NeverSort(sort: BOOLEAN);
>              PUBLIC
>                FUNCTION HereDocument(CONST name: STRING; VAR strings:
> TStringList): BOOLEAN;
>                PROCEDURE Sort; OVERRIDE;
>
> FPC 2.2.0 is giving me duplicate identifier errors for "sort" and
> "strings" above.
>
> I've got nothing against going through the comparatively small amount of
> code affected but I'm a little mystified as to why this is happening:
> the rather elderly version of Delphi I'm using doesn't object, and I
> don't see why there should be a conflict between the class procedure and
> procedure parameter names.

Add {$mode delphi} to the top of your unit. ObjFPC mode is more strict.

Darius

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Unexpected duplicate identifiers

Mark Morgan Lloyd-5
[hidden email] wrote:

>> FPC 2.2.0 is giving me duplicate identifier errors for "sort" and
>> "strings" above.

> Add {$mode delphi} to the top of your unit. ObjFPC mode is more strict.

Thanks, I think that fixes it although I'm still working through the
affected unit.

I presume I'm correct in assuming {$mode delphi} operates strictly on
the syntax of the current unit without affecting cross-unit operations.

Are there cases where it can't be used? Specifically, can it be put in a
Lazarus .lpr file where this is a transcript of a Delphi .dpr?

--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Unexpected duplicate identifiers

Mattias Gaertner
Zitat von Mark Morgan Lloyd <[hidden email]>:

> [hidden email] wrote:
>
> >> FPC 2.2.0 is giving me duplicate identifier errors for "sort" and
> >> "strings" above.
>
> > Add {$mode delphi} to the top of your unit. ObjFPC mode is more strict.
>
> Thanks, I think that fixes it although I'm still working through the
> affected unit.

fix <> workaround ;)


> I presume I'm correct in assuming {$mode delphi} operates strictly on
> the syntax of the current unit without affecting cross-unit operations.
>
> Are there cases where it can't be used? Specifically, can it be put in a
> Lazarus .lpr file where this is a transcript of a Delphi .dpr?

Yes.

Mattias

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Unexpected duplicate identifiers

Mark Morgan Lloyd-5
Mattias Gärtner wrote:

> fix <> workaround ;)

[GRIN] At least nobody's shot me down in flames telling me that Pascal
/has/ to work that way :-)

Just found somewhere that I was applying trim() to a character variable-
not quite sure I meant to do that and FPC scores over Delphi in picking
it up.

>> I presume I'm correct in assuming {$mode delphi} operates strictly on
>> the syntax of the current unit without affecting cross-unit operations.
>>
>> Are there cases where it can't be used? Specifically, can it be put in a
>> Lazarus .lpr file where this is a transcript of a Delphi .dpr?
>
> Yes.

Thanks. I think I read that as the effect /is/ strictly local and it
/can/ be applied to any unit. However in general I'm using it as an aid
to porting existing code, not because I don't like the way FPC does things.

--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal