[Lazarus] Why is there a define switch UseCThreads?

Sven Barth pascaldragon at googlemail.com
Mon Nov 11 00:20:59 CET 2019


Bo Berglund via lazarus <lazarus at lists.lazarus-ide.org> schrieb am So., 10.
Nov. 2019, 23:29:

> I have ported a console application from Windows to Linux (Raspbian
> Buster) and I got to wonder about the check for a defined symbol
> appearing in the beginning of the code as produced by the Lazarus
> template:
>
> uses
>   {$IFDEF UNIX}{$IFDEF UseCThreads}
>   cthreads,
>   {$ENDIF}{$ENDIF}
>
> Would it not be enough to use this instead:
> uses
>   {$IFDEF UNIX}
>   cthreads,
>   {$ENDIF}
>
> Is there a heavy hit on perfortmance or such if the conditional is not
> used but instead just checking if we are on UNIX?
>
> What happens if one does not use threads in ones code but removes the
> conditional UseCThreads as shown above?
>
> For example if I am using Indy10 objects they are threaded so in that
> case I assume I need to use cthreads. But in any other case, how can I
> know that some used package might rely on threads and so needs this
> uses clause?
>
> Basically:
> What damage does it do if cthreads are in the uses clause but no
> thread appears in the program code (yet)?
>

The "damage" is that your application will link against the C library.
Sometimes that's not desirable and quite some FPC code can be used without
that (e.g. the compiler itself does not need to link against the C library
and thus the binary is usable on various Linux distributions and versions).

Regards,
Sven

>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20191111/b904404c/attachment.html>


More information about the lazarus mailing list