[fpc-devel] Issue with Critical sections

Vinzent Hoefler JeLlyFish.software at gmx.net
Thu Apr 5 09:45:34 CEST 2007


On Wednesday 04 April 2007 15:29, Sergei Gorelkin wrote:

> That is exactly what I'm speaking about. Removing 'Windows' from
> uses clause is essentially stopping using it :) And if the code
> continues to compile and work after that, it is just fine.

Sorry, I always forget that most people are not like me and just use 
subroutine names without caring where they come from, while I'm used to 
always prefix the unit names to the subroutines and thus simply 
removing "Windows" from the use clause would not work, because the 
routines suddenly come from a different place.

Well, my opinion and my experience say you should know which routines 
you are actually using. I know that since the days I used DisposeStr 
and the FPC compiled code horribly crashed, because it was the wrong 
one.

> The code I was compiling was already cross-platform (Delphi/Kylix),
> and 'uses Windows' was wrapped by {$IFDEF MSWINDOWS}. In Kylix,
> InitializeCriticalSection and DeleteCriticalSection are implemented
> in SysUtils unit, so any code using these functions continue to work
> under Linux. It was surprise for me that this code could not compile
> with FPC.

I won't judge if FPC is correct here (it's supposed to be Delphi-, not 
Kylix-compatible), but if Borland decided to move those routines, they 
didn't do it right neither. ;)

Well, I'd still suggest to either stick to "System.InitCriticalSection" 
etc. regardless if the Windows unit is included or not (yes, this 
actually *requires* you to prefix it), or just use the SyncObjs unit 
like everyone else out there.


Vinzent.




More information about the fpc-devel mailing list