On Wed, 02 Sep 2020 00:34:23 +0200, Tomas Hajny via fpc-pascal
<fpc-pascal@lists.freepascal.org> wrote:

>On 2020-09-02 00:21, Bo Berglund via fpc-pascal wrote:
>
>  .
>  .
>> Strange because I have read that cthreads must be first in uses in the
>> lpr program files in order to make threads work.
>> How could it work if I add the dependencies, then it would come later
>> or maybe earlier???
>
>The real requirement is that the thread manager needs to be initialized 
>before any threading features are used. If any of the used units uses 
>threading features in its initialization, then such a unit should have 
>cthreads in its own uses section (then this requirement is obviously 
>fulfilled), or cthreads must be listed before that unit in the uses 
>section of your program (and having cthreads as the first unit makes 
>this requirement fulfilled as well).
>

OK, so I made a test by commenting out cthreads in the lpr file and
instead adding it as the first uses in my fpserialport unit, but that
made things even worse...
In this case the application itself would not appear when I started it
from its desktop icon. After trying to see what caused this I started
it from the terminal instead and then I got this:

$ ./SerialTest 
Threading has been used before cthreads was initialized.
Make cthreads one of the first units in your uses clause.
Runtime error 211 at $003958A0
  $003958A0
  $B64FF718

So a different kind of error than the one I had earlier and this
indicates that it really has to be the very first uses in the
application dpr file. Which is what I believed.

Maybe if one has a thread enabled package specified in the project
dependencies, that package's use of cthreads precedes even the lpr
uses clause and therefore the requirement is fulfilled?

Both LazSerial and SdpoSerialLaz uses a read thread, which to me look
identical in their respective source code.
So my read thread is based on theirs with some minor modifications
only...


-- 
Bo Berglund
Developer in Sweden

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to