Sign in Join

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

Mailing lists / fpc-pascal / 2008-12

Unexpected duplicate identifiers

5 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

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

Mark Morgan Lloyd

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]

Reply by email

Unknown author
to Mark Morgan Lloyd
Show quoted text 18 lines
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

Reply by email

Mark Morgan Lloyd
to Unknown author
> 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]

Reply by email

Mattias Gärtner
to Mark Morgan Lloyd

Zitat von Mark Morgan Lloyd :

Show quoted text 9 lines
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 ;)

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

Reply by email

Mark Morgan Lloyd
to Mattias Gärtner
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.

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

Reply by email