Discussion:
Porting from Delphi to FPC - challenge #2.
(too old to reply)
Ozz Nixon
2018-10-01 12:18:52 UTC
Permalink
Type
Line:Array[0..127] of Char;

Var
TmpBugStr:Line;

{later in the code}
Const
TempString : PChar = TmpBugStr;
Ozz Nixon
2018-10-01 12:20:15 UTC
Permalink
Post by Ozz Nixon
Type
Line:Array[0..127] of Char;
Var
TmpBugStr:Line;
{later in the code}
Const
TempString : PChar = TmpBugStr;
Error: Incompatible types: got "Line" expected "PChar

Pointing to the last line. It happens through out the project, I am
compiling -Mdelphi

Ozz
Ozz Nixon
2018-10-01 12:25:51 UTC
Permalink
If I type Cast TmpBugStr as PChar, then the error gets weird:

Error: Incompatible types: got "SYSTEM.PChar" expected "SYSTEM.PChar"
Post by Ozz Nixon
Post by Ozz Nixon
Type
Line:Array[0..127] of Char;
Var
TmpBugStr:Line;
{later in the code}
Const
TempString : PChar = TmpBugStr;
Error: Incompatible types: got "Line" expected "PChar
Pointing to the last line. It happens through out the project, I am
compiling -Mdelphi
Ozz
Denis Kozlov
2018-10-02 11:57:08 UTC
Permalink
PChar is a typed pointer, so you need to point it to the memory location
of TmpBugStr using the "@" operator, like so:

const
Post by Ozz Nixon
Type
Line:Array[0..127] of Char;
Var
TmpBugStr:Line;
{later in the code}
Const
   TempString : PChar = TmpBugStr;
Ozz Nixon
2018-10-02 12:22:16 UTC
Permalink
Got it, thanks!
Post by Denis Kozlov
PChar is a typed pointer, so you need to point it to the memory location
const
Type
Line:Array[0..127] of Char;
Var
TmpBugStr:Line;
{later in the code}
Const
TempString : PChar = TmpBugStr;
Loading...