Sign in Join

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

Mailing lists / fpc-pascal / 2008-05

Baby steps

4 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

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

Kristofer Skaug

Hi all,

I've taken a stroll into Lazarus-/FPC-land, trying to port some Delphi units that have served me well for a long time.
Here are my inevitable newbie problems:

1) Have been reading the FAQs and other things but cannot seem to find the referenced sections in the FPC manuals that contain Delphi vs FPC language (in)compatability notes. The RTL manual doesn't appear to load from the FPC website.

2) How do I convert a Delphi function like this:

function PtrAt(p:pointer; const Offset:LongWord):pointer;
begin
  Result := Ptr(LongWord(p)+Offset);
end;

FPC barked at my use of Ptr(), saying:
"Error: Wrong number of parameters specified for call to "ptr"" And indeed in systemh.inc, "ptr" is defined as:
Function ptr(sel,off:Longint):farpointer; (...)
which appears to be some kind of TP compatability function. But the modern Delphi Ptr() function takes only a 32-bit numeric address as argument. Is there an equivalent for this in FPC?
For the record, I'm *not* primarily interested in trying to make FPC "act like" Delphi, if this costs me Cross-platform flexibility. I'd rather understand how to create the equivalent function in 'pure' FPC.

3) Is there an FPC equivalent of DUnit? I have more than 150KLines' worth of unit tests that would be a great help in the migration exercise, if I could find a way to re-use them...

4) Probably none of your business, but anyway: I tried registering for the Lazarus forums (twice, in fact, for 2 different e-mail addresses), but never received a registration confirmation/password. Is that a known issue? Whom can I contact to solve this - I do not see any contact addresses on the the website.

thanks for helping me with the baby steps :-)

Kristofer

Jonas Maebe
to Kristofer Skaug
Kristofer Skaug wrote 7 lines
1) Have been reading the FAQs and other things but cannot seem to find the referenced sections in the FPC manuals that contain Delphi vs FPC language (in)compatability notes. The RTL manual doesn't appear to load from the FPC website.

There's a list available at http://wiki.freepascal.org/Code_Conversion_Guide

It should indeed probably be referenced from the FAQ or so. A number of the points raised at http://www.freepascal.org/port.var are also valid when coming from Delphi rather than from Turbo Pascal.

Show quoted text 15 lines
2) How do I convert a Delphi function like this: function PtrAt(p:pointer; const Offset:LongWord):pointer; begin Result := Ptr(LongWord(p)+Offset); end; FPC barked at my use of Ptr(), saying: "Error: Wrong number of parameters specified for call to "ptr"" And indeed in systemh.inc, "ptr" is defined as: Function ptr(sel,off:Longint):farpointer; (...) which appears to be some kind of TP compatability function. But the modern Delphi Ptr() function takes only a 32-bit numeric address as argument. Is there an equivalent for this in FPC?

Simply use a Pointer-typecast (that will also work in Delphi). In Delphi Ptr() is probably internally also simply converted ta Pointer- typecast.

I can't help with the other issues, but others probably can.

Jonas

Tiziano De Togni
to Kristofer Skaug: I've taken a stroll into Lazarus-/FPC-land, trying to port some Delphi units that have…

Kristofer Skaug ha scritto:

Show quoted text 6 lines
Hi all, 3) Is there an FPC equivalent of DUnit? I have more than 150KLines' worth of unit tests that would be a great help in the migration exercise, if I could find a way to re-use them...

yes, fpcunit is the answer:
http://www.freepascal.org/docs-html/fpcunit.pdf

tiziano ______________________________________ http://digilander.libero.it/tizzziano/
Kristofer Skaug

Jonas and Tiziano, thanks both for your helpful answers! This should certainly allow me to make good progress.

Kristofer