[fpc-pascal] cthreads unit

Jonas Maebe jonas.maebe at elis.ugent.be
Sun Feb 17 19:50:14 CET 2008


On 17 Feb 2008, at 19:42, ik wrote:

> I'm trying to use the pthread_self function that supposed to be
> existed at cthreads unit.
> However the compiler tell me that it does not know "pthread_self".

It's only imported into that unit (in the implementation), it's not  
exported. The cthreads unit only installs a thread manager, it does  
not expose any implementation details (that's the whole point of that  
unit).

> I'm using Linux 64 bit (so I can't use libc), using fpc 2.2.0 .
> Looking at the source of cthreads.pp, it does have an include for
> pthread.inc file, that does contain dynamic/static linking of the
> function, so what am I missing ?

If you want to use the RTL support for threading, use the generic RTL  
routines and not OS-specific ones. There is e.g. a GetCurrentThreadId  
function (but don't count on it returning the same value as  
pthread_self).

If you want to program with pthreads directly, use the pthreads unit  
instead.


Jonas



More information about the fpc-pascal mailing list