Recent

Author Topic: Incompatible type in MTProcs  (Read 246 times)

LemonParty

  • Sr. Member
  • ****
  • Posts: 388
Incompatible type in MTProcs
« on: November 14, 2025, 06:14:20 pm »
Hello.

I am trying to compile this parallel code:
Code: Pascal  [Select][+][-]
  1. function ReadFilesParallel(const aFileList: TStringDynArray): TBytesDynArray;
  2.  
  3.   procedure _ReadFilesParallel(Index: PtrInt; Data: Pointer; Item: TMultiThreadProcItem);
  4.   begin
  5.     ReadFileToBytes(aFileList[Index], Result[Index]);
  6.   end;
  7.  
  8. begin
  9.   SetLength(Result, Length(aFileList));
  10.  
  11.   ProcThreadPool.DoParallelNested(@_ReadFilesParallel, 0, Length(aFileList) - 1, nil, 4);
  12. end;

Error occurs on line ProcThreadPool.DoParallelNested(@_ReadFilesParallel, 0, Length(aFileList) - 1, nil, 4); and it says:
Quote
Error: Incompatible type for arg no. 1: Got "<address of procedure(QWord;Pointer;TMultiThreadProcItem) is nested;Register>", expected "<procedure variable type of procedure(Int64;Pointer;TMultiThreadProcItem) is nested;Register>"
What is wrong?
Lazarus v. 4.99. FPC v. 3.3.1. Windows 11

cdbc

  • Hero Member
  • *****
  • Posts: 2505
    • http://www.cdbc.dk
Re: Incompatible type in MTProcs
« Reply #1 on: November 14, 2025, 06:26:49 pm »
Hi
Are you sure the error-message belongs to the code shown?!?
Code: Pascal  [Select][+][-]
  1. Index: PtrInt;
...or have you changed the code after run and before posting?
Anyway, you can then try and change from 'PtrInt' to 'PtrUInt', that's the param it's whining about... {in reverse that is...}
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE6/QT6 -> FPC Release -> Lazarus Release &  FPC Main -> Lazarus Main

LemonParty

  • Sr. Member
  • ****
  • Posts: 388
Re: Incompatible type in MTProcs
« Reply #2 on: November 14, 2025, 06:31:06 pm »
Oh, sorry. I posted the wrong message. Here the right one:
Quote
Error: Incompatible type for arg no. 1: Got "<address of procedure(Int64;Pointer;TMultiThreadProcItem) is nested;Register>", expected "<procedure variable type of procedure(Int64;Pointer;TMultiThreadProcItem) is nested;Register>"
Lazarus v. 4.99. FPC v. 3.3.1. Windows 11

LemonParty

  • Sr. Member
  • ****
  • Posts: 388
Re: Incompatible type in MTProcs
« Reply #3 on: November 14, 2025, 06:36:59 pm »
I found the solution. I missed {$ModeSwitch nestedprocvars} in the begin of a program.
Lazarus v. 4.99. FPC v. 3.3.1. Windows 11

 

TinyPortal © 2005-2018