Recent

Author Topic: [SOLVED] Compile Error Read Write Seek etc.  (Read 1674 times)

convertDtoL

  • Newbie
  • Posts: 5
[SOLVED] Compile Error Read Write Seek etc.
« on: December 10, 2018, 12:34:16 pm »
Hi All,

I have a question regarding compiling a Delphi project to Lazarus.
When running the compilation of the following script:

{ Implements only the write method of OLE IStream on VCL TWriter }
  TWriterAdapter = class(TInterfacedObject, ISequentialStream, IStream)
  private
    Writer: TWriter;
  public
    constructor Create(AWriter: TWriter);
    function Read(pv: Pointer; cb: Longint; pcbRead: PLongint): HResult; stdcall;
    function Write(pv: Pointer; cb: Longint; pcbWritten: PLongint): HResult; stdcall;
    function Seek(dlibMove: Largeint; dwOrigin: Longint;
      out libNewPosition: Largeint): HResult; stdcall;
    function SetSize(libNewSize: Largeint): HResult; stdcall;
    function CopyTo(stm: IStream; cb: Largeint; out cbRead: Largeint;
      out cbWritten: Largeint): HResult; stdcall;
    function Commit(grfCommitFlags: Longint): HResult; stdcall;
    function Revert: HResult; stdcall;
    function LockRegion(libOffset: Largeint; cb: Largeint;
      dwLockType: Longint): HResult; stdcall;
    function UnlockRegion(libOffset: Largeint; cb: Largeint;
      dwLockType: Longint): HResult; stdcall;
    function Stat(out statstg: TStatStg; grfStatFlag: Longint): HResult;
      stdcall;
    function Clone(out stm: IStream): HResult; stdcall;
  end;   

I get the following error:
Streamable.pas(109,20) Error: No matching implementation for interface method "Read(Pointer;LongWord;PDWord):LongInt; StdCall;" found
Streamable.pas(109,20) Error: No matching implementation for interface method "Write(Pointer;LongWord;PDWord):LongInt; StdCall;" found
Streamable.pas(109,20) Error: No matching implementation for interface method "Read(Pointer;LongWord;PDWord):LongInt; StdCall;" found
Streamable.pas(109,20) Error: No matching implementation for interface method "Write(Pointer;LongWord;PDWord):LongInt; StdCall;" found
Streamable.pas(109,20) Error: No matching implementation for interface method "Seek(QWord;LongInt;out QWord):LongInt; StdCall;" found
Streamable.pas(109,20) Error: No matching implementation for interface method "SetSize(QWord):LongInt; StdCall;" found
Streamable.pas(109,20) Error: No matching implementation for interface method "CopyTo(IStream;QWord;out QWord;out QWord):LongInt; StdCall;" found
Streamable.pas(109,20) Error: No matching implementation for interface method "LockRegion(QWord;QWord;LongInt):LongInt; StdCall;" found
Streamable.pas(109,20) Error: No matching implementation for interface method "UnlockRegion(QWord;QWord;LongInt):LongInt; StdCall;" found


In another thread I found a way to change the StdCall to {$IFDEF WINDOWS}stdcall {$ELSE}CDECL{$ENDIF} but that does not solve this issue.

Please let me know if you are able to help me out.

Thanks in advance!
« Last Edit: December 12, 2018, 07:55:07 am by convertDtoL »

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11444
  • FPC developer.
Re: Compile Error Read Write Seek etc.
« Reply #1 on: December 10, 2018, 12:39:46 pm »
There are a few typical things that could cause this:

  • Delphi uses signed types in some interfaces while MSDN specifies it should be unsigned.  (e.g. make the longints in read and write dword/pdwords, as you can see in the signatures in the errors)
  • You used an old Delphi version without 64-bit unsigned support, and some other workaround is used (possibily the largeint stuff. The errors seem to indicate 64-bit unsigned (qword) is expected)
  • Unicode vs non unicode issues (iow D2007- vs D2009+), though that doesn't seem to be the case here

Read the signatures in the errormessages carefully, and try to match your implementation to them.

convertDtoL

  • Newbie
  • Posts: 5
Re: Compile Error Read Write Seek etc.
« Reply #2 on: December 10, 2018, 12:44:11 pm »
Thanks for the fast response Marcov!

Indeed we used a really old version of Delphi.
What would you suggest that would be the best way of solving this issue?

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11444
  • FPC developer.
Re: Compile Error Read Write Seek etc.
« Reply #3 on: December 10, 2018, 02:30:00 pm »
Thanks for the fast response Marcov!

Indeed we used a really old version of Delphi.
What would you suggest that would be the best way of solving this issue?

Adapt the definitions in your code to the ones in the errors.

convertDtoL

  • Newbie
  • Posts: 5
Re: Compile Error Read Write Seek etc.
« Reply #4 on: December 11, 2018, 11:41:54 am »

Adapt the definitions in your code to the ones in the errors.

Sorry I am really new to all of this. I don't understand what I have to adapt.
I tried to adapt the code to the ones in the error but it does not work.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11444
  • FPC developer.
Re: Compile Error Read Write Seek etc.
« Reply #5 on: December 11, 2018, 11:55:36 am »
I did it, and it was indeed most signedness, but the types can be confusing. keep in mind that longint=integer, qword=largeuint and int64=largeint.

Anyway, here is the code that I got compiling in full. Please study it thoroughly, so that you understand it for the next time.

Code: Pascal  [Select][+][-]
  1. {$mode delphi}
  2. uses classes,sysutils,types;
  3.  
  4. type
  5.  TWriterAdapter = class(TInterfacedObject, ISequentialStream, IStream)
  6.   private
  7.     Writer: TWriter;
  8.   public
  9.     constructor Create(AWriter: TWriter);
  10.     function Read(pv: Pointer; cb: DWORD; pcbRead: PDWORD): HResult; stdcall;
  11.     function Write(pv: Pointer; cb: DWORD; pcbWritten: PDWORD): HResult; stdcall;
  12.     function Seek(dlibMove: Largeint; dwOrigin: Longword;
  13.       out libNewPosition: Largeuint): HResult; stdcall;
  14.     function SetSize(libNewSize: Largeuint): HResult; stdcall;
  15.     function CopyTo(stm: IStream; cb: Largeuint; out cbRead: Largeuint;
  16.       out cbWritten: Largeuint): HResult; stdcall;
  17.     function Commit(grfCommitFlags: Longword): HResult; stdcall;
  18.     function Revert: HResult; stdcall;
  19.     function LockRegion(libOffset: Largeuint; cb: Largeuint;
  20.       dwLockType: Longword): HResult; stdcall;
  21.     function UnlockRegion(libOffset: Largeuint; cb: Largeuint;
  22.       dwLockType: Longword): HResult; stdcall;
  23.     function Stat(out statstg: TStatStg; grfStatFlag: Longword): HResult;
  24.       stdcall;
  25.     function Clone(out stm: IStream): HResult; stdcall;
  26.   end;
  27.  
  28.  
  29. { TWriterAdapter }
  30.  
  31. function TWriterAdapter.Clone(out stm: IStream): HResult;
  32. begin
  33.  
  34. end;
  35.  
  36. function TWriterAdapter.Commit(grfCommitFlags: longword): HResult;
  37. begin
  38.  
  39. end;
  40.  
  41. function TWriterAdapter.CopyTo(stm: IStream; cb: Largeuint; out cbRead,
  42.   cbWritten: Largeuint): HResult;
  43. begin
  44.  
  45. end;
  46.  
  47. constructor TWriterAdapter.Create(AWriter: TWriter);
  48. begin
  49.  
  50. end;
  51.  
  52. function TWriterAdapter.LockRegion(libOffset, cb: Largeuint;
  53.   dwLockType: longword): HResult;
  54. begin
  55.  
  56. end;
  57.  
  58. function TWriterAdapter.Read(pv: Pointer; cb: DWORD;
  59.   pcbRead: PDWORD): HResult;
  60. begin
  61.  
  62. end;
  63.  
  64. function TWriterAdapter.Revert: HResult;
  65. begin
  66.  
  67. end;
  68.  
  69. function TWriterAdapter.Seek(dlibMove: Largeint; dwOrigin: longword;
  70.   out libNewPosition: Largeuint): HResult;
  71. begin
  72.  
  73. end;
  74.  
  75. function TWriterAdapter.SetSize(libNewSize: Largeuint): HResult;
  76. begin
  77.  
  78. end;
  79.  
  80. function TWriterAdapter.Stat(out statstg: TStatStg;
  81.   grfStatFlag: longword): HResult;
  82. begin
  83.  
  84. end;
  85.  
  86. function TWriterAdapter.UnlockRegion(libOffset, cb: Largeuint;
  87.   dwLockType: longword): HResult;
  88. begin
  89.  
  90. end;
  91.  
  92. function TWriterAdapter.Write(pv: Pointer; cb: DWORD;
  93.   pcbWritten: PDWORD): HResult;
  94. begin
  95.  
  96. end;
  97.  
  98. begin
  99. end.
  100.  

convertDtoL

  • Newbie
  • Posts: 5
Re: Compile Error Read Write Seek etc.
« Reply #6 on: December 11, 2018, 01:28:32 pm »
Thank you Marcov,

The first sentence in your answer makes it all clear to me!

I have more of these problems in the script but I think I can solve all of them based on those 3 words.

 

TinyPortal © 2005-2018