[fpc-pascal] Windows unit and SyncObjs unit clash

Graeme Geldenhuys graemeg.lists at gmail.com
Wed Mar 26 11:37:43 CET 2008


I've noticed this ages ago and found a work-around, but never reported
it. I hit the same error again today and thought this time I would
mention it.

In tiOPF we have some IFDEF's for the 'Windows' unit. Some units also
use the 'SyncObjs' unit for critical section handling. If 'SyncObjs'
unit appears before the 'Windows' unit, our code fails to compile with
a error referring to the TCriticalSection class.

Does anybody know about this?  Is there any permanent fix to that FPC
doesn't depend on specific order in uses clause?

I'm now using FPC 2.2.0, but this issue has been around since 2.0.2.

------------[ copy ]------------------
C:\Programming\tiOPF2\Source\Core\tiUtils.pas(3491,13) Error: Unknown
record field identifier "ENTER"

C:\Programming\tiOPF2\Source\Core\tiUtils.pas(3491,18) Error: Illegal expression

C:\Programming\tiOPF2\Source\Core\tiUtils.pas(3497,15) Error: Unknown
record field identifier "LEAVE"

C:\Programming\tiOPF2\Source\Core\tiUtils.pas(3497,20) Error: Illegal expression

C:\Programming\tiOPF2\Source\Core\tiUtils.pas(3503,13) Error: Unknown
record field identifier "ENTER"

C:\Programming\tiOPF2\Source\Core\tiUtils.pas(3503,18) Error: Illegal expression

C:\Programming\tiOPF2\Source\Core\tiUtils.pas(3509,15) Error: Unknown
record field identifier "LEAVE"

C:\Programming\tiOPF2\Source\Core\tiUtils.pas(3509,20) Error: Illegal expression

C:\Programming\tiOPF2\Source\Core\tiUtils.pas(3526,32) Error: Unknown
record field identifier "CREATE"

C:\Programming\tiOPF2\Source\Core\tiUtils.pas(3532,13) Error: Unknown
record field identifier "FREE"

C:\Programming\tiOPF2\Source\Core\tiUtils.pas(3532,17) Error: Illegal expression

C:\Programming\tiOPF2\Source\Core\tiUtils.pas(3544,13) Error: Unknown
record field identifier "ENTER"

C:\Programming\tiOPF2\Source\Core\tiUtils.pas(3544,18) Error: Illegal expression

C:\Programming\tiOPF2\Source\Core\tiUtils.pas(3548,15) Error: Unknown
record field identifier "LEAVE"

C:\Programming\tiOPF2\Source\Core\tiUtils.pas(3548,20) Error: Illegal expression

C:\Programming\tiOPF2\Source\Core\tiUtils.pas(3560,13) Error: Unknown
record field identifier "ENTER"

C:\Programming\tiOPF2\Source\Core\tiUtils.pas(3560,18) Error: Illegal expression

C:\Programming\tiOPF2\Source\Core\tiUtils.pas(3564,15) Error: Unknown
record field identifier "LEAVE"

C:\Programming\tiOPF2\Source\Core\tiUtils.pas(3564,20) Error: Illegal expression

C:\Programming\tiOPF2\Source\Core\tiUtils.pas(3569) Fatal: There were
19 errors compiling module, stopping

------------[ end ]-------------------

And here is an example of where the cursor lands to show the error...

function TtiMultiReadExclusiveWriteSynchronizer.LockForRead: boolean;


  FCritSect.Enter;          // <<<<<<<<<  Cursor showing error


    result:= CanLockForRead;

    if Result then






  - Graeme -

fpGUI - a cross-platform Free Pascal GUI toolkit

More information about the fpc-pascal mailing list