[fpc-pascal] alternatives for "cwstring" and "cthreads"

Jonas Maebe jonas.maebe at elis.ugent.be
Fri Dec 11 17:04:43 CET 2015


Graeme Geldenhuys wrote on Fri, 11 Dec 2015:

> Both the "cwstring and "cthreads" units (as per the documentation) says
> that it links to the C library of unix systems.
>
> Does this make your programs more dependent on a specific version of the
> C library? Or can you run a current unix program (say compiled on the
> latest Ubuntu Linux) on say a 10 year old Linux? [lets assume it is a
> console or daemon application, not GUI]

Most likely yes. E.g., a dummy program containing just this:

***
uses
   cthreads, cwstring;
begin
end.
***

works fine when compiled on
"Linux xxx 2.6.18-194.11.4.el5 #1 SMP Tue Sep 21 06:46:41 EDT 2010  
x86_64 x86_64 x86_64 GNU/Linux" against GLibC 2.5 and when run on  
"Linux YYY 3.13.0-48-generic #80-Ubuntu SMP Thu Mar 12 11:16:15 UTC  
2015 x86_64 x86_64 x86_64 GNU/Linux" with EGLibC 2.19. Vice verse  
works fine too.

> Are there any drawbacks in letting your program link to such a C library?

The biggest drawback is that you need to have the libraries available  
when cross-compiling from another platform.

> Are there alternatives to those units that don't link to such a C
> library, but still allows your unix programs to use threading and
> unicode text (new FPC codepage-aware String)?

If you don't mind your program's size blowing up massively due to  
having to include all of the unicode transcoding tables, you can use  
the cpall unit in combination with the fpwidestring unit instead of  
cwstring (or you can ship the tables as external files, but that won't  
reduce their size).

No one has implemented a thread manager in Pascal, afaik. It would  
also be very OS-specific if someone did: it would be Linux-specific,  
and depending on which features of the kernel it uses, possibly less  
backward compatible than the cthreads unit.


Jonas



More information about the fpc-pascal mailing list