Recent

Author Topic: Code works on FPC (IDE) but not in Lazarus IDE  (Read 7478 times)

AkiFoblesia

  • New member
  • *
  • Posts: 9
Code works on FPC (IDE) but not in Lazarus IDE
« on: September 04, 2006, 02:54:16 am »
Hello to all :D

im starting studying lazarus hand in hand with freepascal.

im wondering why in a given unit w/ two class types - where one is a subclass of the other - having a field (or variable) of similar names would cause lazarus (0.9.16 beta) to complain of duplicate identifier while free pascal (2.0.4) would accept the same code. my code was used under 'Delphi compatibility option' for both fpc and lazarus.

for example, the following code snippet will be accepted by FPC IDE but lazarus would complain of duplicate identifier, which is 'ID'.

===================================

interface {section}

type
  MyClass = class
    ID : integer;
    procedure MyProc;
  end;
 
  NewClass = class(MyClass)
    ID : string;
  end;

{lazarus complains the second 'ID' of being a duplicate identifier; fpc does not and compiles successfully. If I change the second ID variable in another name w/c is unique, lazarus would then compile the code succesfully.}

===================================

btw, the project was a custom program for lazarus, selected on 'Project -> New Project -> Custom Program'.


thanks in advance for the answer :)

CCRDude

  • Hero Member
  • *****
  • Posts: 615
RE: Code works on FPC (IDE) but not in Lazarus IDE
« Reply #1 on: September 04, 2006, 10:03:29 am »
From memory, so it might not be exactly correctly, but if you use the IDE, I think something like {$MODE OBJFPC} or similar is predefined, while compiling with fpc, you would have to define it yourself?

AkiFoblesia

  • New member
  • *
  • Posts: 9
RE: Code works on FPC (IDE) but not in Lazarus IDE
« Reply #2 on: September 04, 2006, 10:23:51 am »
that gave me an idea.

lazarus ide has the {$MODE OBJFPC}{$H+} pre-written in both progam and unit files.

i tried deleting the {$MODE OBJFPC} and it accepted the code :D

 

TinyPortal © 2005-2018