[Lazarus] TRTLCriticalSection

patspiper patspiper at gmail.com
Tue Feb 25 11:56:30 CET 2014


On 25/02/14 12:22, Antonio Fortuny wrote:
> Hi Folks.
>
> Lazarus 1.0.2, FPC 2.6.2, Win32 and Linux x86_64

That's an old Lazarus version. Did you test with the most recent one?

> Something goes wrong with TRTRCriticalSection. There is a difference 
> between Windows and Linux.
> In a program which will run on Win32 and Linux x86_64, using threads 
> and all this stuff I need to protect some code from multi-threading 
> access.
> One critical section looks enough to do the job.
> So i code this in Win32 and Linux:
>
> Interface uses clause is:
> uses
>   {$IFDEF LINUX}
>   CThreads,
>   {$ENDIF}
>   syncobjs,
>   {$IFDEF MSWINDOWS}
>   windows,
>   {$ENDIF}
>   {$IFDEF LINUX}
>   LCLIntf,
>   {$ENDIF}
>   Classes,
>   IdContext,
>   uSimplelogger,
>   sitacom,
>   MessageQ,
>   autoupdateTCPthread,
>   sqldb,
>   SysUtils;
>     FIniCriticalSection: TRTLCriticalSection;
>     ...
>     InitializeCriticalSection(FIniCriticalSection); <----------------- 
> compilation error
>     ...
>     EnterCriticalSection(FIniCriticalSection);
>     try
>         ... do a lot of things
>     finally
>         LeaveCriticalSection(FIniCriticalSection);
>     end
>     ...
>
> On the above line marked as compilation error the compiler complains 
> with the message
> autoupdateserverthread.pas(255,48) Error: Call by var for arg no. 1 
> has to match exactly: Got "TRTLCriticalSection" expected "QWord"

Try putting syncobjs after LCLIntf in the uses section.

What you're seeing may be related to bug report 
http://bugs.freepascal.org/view.php?id=25187

> *winapi.inc*(650,11) Hint: Found declaration: 
> InitializeCriticalSection(var QWord);
> winapi ??? Why on Linux ?
> No way to get rid of this compilation error
> In Win32 the program compiles and runs without errors.
>
> Some help would be appreciated.

This is odd. What is the output of View/IDE Internals/About FPC and 
About IDE?

Stephano
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20140225/ee72d319/attachment-0003.html>


More information about the Lazarus mailing list