[fpc-devel] Issue with Critical sections
Hello, I was porting to Linux some Windows code which uses critical sections API, and got 'Identifier not found' error on InitializeCriticalSection and DeleteCriticalSection symbols. After searching through RTL code, I discovered that abovementioned functions are named InitCriticalSection and DoneCriticalSection. At the same time, the EnterCriticalSection and LeaveCriticalSection are not renamed, so code using them compiles without errors. Why this inconsistency? Should I supply a patch that adds Initialize/DeleteCriticalSection as aliases for Init/DoneCriticalSection? Regards, Sergei ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] Issue with Critical sections
On Wednesday 04 April 2007 10:33, Sergei Gorelkin wrote: I was porting to Linux some Windows code which uses critical sections API, and got 'Identifier not found' error on InitializeCriticalSection and DeleteCriticalSection symbols. If I had to guess, I'd say this is probably because those identifiers come from the Windows unit. After searching through RTL code, I discovered that abovementioned functions are named InitCriticalSection and DoneCriticalSection. At the same time, the EnterCriticalSection and LeaveCriticalSection are not renamed, so code using them compiles without errors. Why this inconsistency? Because one is the RTL abstraction on the different OSes, the other one is the direct Windows-API-Call. Should I supply a patch that adds Initialize/DeleteCriticalSection as aliases for Init/DoneCriticalSection? No, I'd suggest to fix your code. Regards, Vinzent. ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re[2]: [fpc-devel] Issue with Critical sections
Wednesday, April 04, 2007, 3:00:55 PM, Vinzent wrote: After searching through RTL code, I discovered that abovementioned functions are named InitCriticalSection and DoneCriticalSection. At the same time, the EnterCriticalSection and LeaveCriticalSection are not renamed, so code using them compiles without errors. Why this inconsistency? VH Because one is the RTL abstraction on the different OSes, the other one VH is the direct Windows-API-Call. But EnterCriticalSection/LeaveCriticalSection also exist in Windows API. And they are implemented in System unit without changing names. Therefore, to make my code cross-platform, I have only to remove Windows from uses clause - then cross-platform versions from System unit will be used. This is fine. Contrary, InitlalizeCriticalSection and DeleteCriticalSection are renamed. This makes me wonder. All four functions belong to a single logical group and are being affected by whatever cross-platform issues in the same way. One would expect that either all four are renamed, or all four left with original names - this is the reason for my question. -- Best regards, Sergei ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] Issue with Critical sections
Sergei Gorelkin wrote: But EnterCriticalSection/LeaveCriticalSection also exist in Windows API. And they are implemented in System unit without changing names. Therefore, to They shouldn't be exposed publicly in the system unit. Micha ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] Issue with Critical sections
On Wednesday 04 April 2007 12:59, Sergei Gorelkin wrote: But EnterCriticalSection/LeaveCriticalSection also exist in Windows API. And they are implemented in System unit without changing names. Therefore, to make my code cross-platform, I have only to remove Windows from uses clause - then cross-platform versions from System unit will be used. This is fine. No. If you want to be cross-platform just do not use the Windows unit at all. Rather only use the functionality provided by the system unit, regardless of the compilation target. The Windows unit should generally only included if you write platform specific code and such code should be separated in its own include file or even unit anyway. Vinzent. ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] Issue with Critical sections
On Wednesday 04 April 2007 13:13, Micha Nelissen wrote: Sergei Gorelkin wrote: But EnterCriticalSection/LeaveCriticalSection also exist in Windows API. And they are implemented in System unit without changing names. Therefore, to They shouldn't be exposed publicly in the system unit. Why's that? At least it's documented that way. And I don't see any harm in doing so. Vinzent. ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] Issue with Critical sections
Wednesday, April 04, 2007, 5:13:43 PM, Vinzent wrote: VH On Wednesday 04 April 2007 12:59, Sergei Gorelkin wrote: But EnterCriticalSection/LeaveCriticalSection also exist in Windows API. And they are implemented in System unit without changing names. Therefore, to make my code cross-platform, I have only to remove Windows from uses clause - then cross-platform versions from System unit will be used. This is fine. VH No. If you want to be cross-platform just do not use the Windows unit VH at all. Rather only use the functionality provided by the system unit, VH regardless of the compilation target. VH The Windows unit should generally only included if you write platform VH specific code and such code should be separated in its own include file VH or even unit anyway. 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. 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. -- Best regards, Sergei ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] Issue with Critical sections
En/na Sergei Gorelkin ha escrit: 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. Any reason why not to use syncobjs? (I'm just curious, since that's the unit I used when I needed critical sections). Bye -- Luca A: Because it destroys the flow of the conversation Q: Why is it bad? A: No, it's bad. Q: Should I top post in replies to mailing lists? ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
[fpc-devel] website translation
Go to translatable web site leads to error dump: can't read locale_admin_url: no such variable while executing lang::util::localize ${locale_admin_url} invoked from within if {[string equal [ad_quotehtml [lang::util::localize ${translatable_website}]] 1]} { append __adp_output lifont color=\#199b02\... (uplevel body line 246) invoked from within uplevel { set __adp_output ... ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
[fpc-devel] website translation, question
1. I18N Message Conflicts shows pl_PL locale conflicts. Is it right or is it wrong? (I want to check ru conflicts if any.) 2. Would it be better if this or similar questions were posted as bugs? ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel