<div dir="auto"><div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Bo Berglund via lazarus <<a href="mailto:lazarus@lists.lazarus-ide.org">lazarus@lists.lazarus-ide.org</a>> schrieb am Mo., 11. Nov. 2019, 08:38:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Mon, 11 Nov 2019 00:20:59 +0100, Sven Barth via lazarus<br>
<<a href="mailto:lazarus@lists.lazarus-ide.org" target="_blank" rel="noreferrer">lazarus@lists.lazarus-ide.org</a>> wrote:<br>
<br>
>Bo Berglund via lazarus <<a href="mailto:lazarus@lists.lazarus-ide.org" target="_blank" rel="noreferrer">lazarus@lists.lazarus-ide.org</a>> schrieb am So., 10.<br>
>Nov. 2019, 23:29:<br>
><br>
>> I have ported a console application from Windows to Linux (Raspbian<br>
>> Buster) and I got to wonder about the check for a defined symbol<br>
>> appearing in the beginning of the code as produced by the Lazarus<br>
>> template:<br>
>><br>
>> uses<br>
>> {$IFDEF UNIX}{$IFDEF UseCThreads}<br>
>> cthreads,<br>
>> {$ENDIF}{$ENDIF}<br>
>><br>
>> Would it not be enough to use this instead:<br>
>> uses<br>
>> {$IFDEF UNIX}<br>
>> cthreads,<br>
>> {$ENDIF}<br>
>><br>
>> Is there a heavy hit on perfortmance or such if the conditional is not<br>
>> used but instead just checking if we are on UNIX?<br>
>><br>
>> What happens if one does not use threads in ones code but removes the<br>
>> conditional UseCThreads as shown above?<br>
>><br>
>> For example if I am using Indy10 objects they are threaded so in that<br>
>> case I assume I need to use cthreads. But in any other case, how can I<br>
>> know that some used package might rely on threads and so needs this<br>
>> uses clause?<br>
>><br>
>> Basically:<br>
>> What damage does it do if cthreads are in the uses clause but no<br>
>> thread appears in the program code (yet)?<br>
>><br>
><br>
>The "damage" is that your application will link against the C library.<br>
>Sometimes that's not desirable and quite some FPC code can be used without<br>
>that (e.g. the compiler itself does not need to link against the C library<br>
>and thus the binary is usable on various Linux distributions and versions).<br>
><br>
<br>
So if one does not enable use of cthreads there are still threads<br>
available also on Linux?<br>
I interpreted the existence of this switch as "if you want to use<br>
threads on Linux you need to enable UseCThreads"...<br>
<br>
If I do not have cthreads as a uses item but still want to use for<br>
example Indy10, will it still work?<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">You asked what the damage is if one does not use threads. </div><div dir="auto"><br></div><div dir="auto">If you use threads then you *must* use the cthreads unit on Unix platforms. </div><div dir="auto"><br></div><div dir="auto">Regards, </div><div dir="auto">Sven </div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
</blockquote></div></div></div>