Sign in Join

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

Mailing lists / lazarus / 2015-11

Different behavior of method and class variables

3 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

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

Leonardo M. Ramé

I'm creating a class out of a C header converted to pascal using h2pas.

I created this type:

pRobotArray = ^TArray0toMAX_ROBOT_DRIVES1OfHANDLE;

If I use it inside a method, like this:

procedure TMyClass.myMethod;
var
   lRobots: pRobotArray;
begin
   getRobots(lHRobots);
   lRobots := @lHRobots; // this works ok.
end;

If I add an FRobots var to my class:

TRobotClass = class
private
   FRobots: pRobotArray;
public
   procedure myMethod;
end;
procedure TMyClass.myMethod;
begin
   getRobots(lHRobots);
   FRobots := @lHRobots; // I get an external SIGSEGV.
end;

Why the difference?.

Regards,

Reply by email

Mattias Gaertner
to Leonardo M. Ramé
Show quoted text 14 lines
I'm creating a class out of a C header converted to pascal using h2pas. I created this type: pRobotArray = ^TArray0toMAX_ROBOT_DRIVES1OfHANDLE; If I use it inside a method, like this: procedure TMyClass.myMethod; var lRobots: pRobotArray; begin getRobots(lHRobots); lRobots := @lHRobots; // this works ok.

No, lHRobots is not defined.

Show quoted text 18 lines
end; If I add an FRobots var to my class: TRobotClass = class private FRobots: pRobotArray; public procedure myMethod; end; procedure TMyClass.myMethod; begin getRobots(lHRobots); FRobots := @lHRobots; // I get an external SIGSEGV. end; Why the difference?.

Please provide a complete example.

Mattias

Reply by email