[fpc-pascal] cthreads

Michael Van Canneyt michael at freepascal.org
Fri Jul 25 12:33:42 CEST 2014

On Fri, 25 Jul 2014, Mark Morgan Lloyd wrote:

> Michael Van Canneyt wrote:
>> On Fri, 25 Jul 2014, Juha Manninen wrote:
>>> I was asked why a threaded application compiles on Linux without "uses
>>> cthreads" but it does not work.
>>> cthreads must _always_ be added to uses section.
>>> I had no answer to that. IMO such errors should be trapped at
>>> compile-time, not at run-time.
>>> Could it be fixed somehow?
>> No, because there is no way to detect that threads are actually used in the 
>> program.
>> I will add a remark in the classes unit TThread class documentation, to 
>> make it even more obvious.
> Is there scope for improving the error message?
> Is there a scenario in which a program that sometimes uses threads (e.g. if 
> it realises it's being asked to do a big job which can be parallelised) could 
> start without giving the error message? This would make the situation more 
> serious, since it would require that the programmer did some /real/ testing 
> before shipping his code :-)

Not sure what you mean.

The error only appears if you call a function that relies on the threading manager, 
never at the start of the program. It's slightly more complicated than this, but 
it boils down to that.

So the fact that the program started doesn't mean there won't be an error further 
down the line. But that is IMHO no different from many other programming errors, 
such as trying to save preferences in a file in a directory that doesn't exist. 
You should always test all cases.


More information about the fpc-pascal mailing list