[fpc-devel] Widestring and reference counting

Martin Schreiber fpmse at bluewin.ch
Sun Nov 25 10:49:02 CET 2007


On Saturday 24 November 2007 13.22, Graeme Geldenhuys wrote:
> Hi,
>
>
> I was reading a article on Delphi's WideString support.  It mentions
> that under Delphi, WideStrings are not reference counted, but under
> Kylix they are.
> http://tobias.feedian.com/2007/05/24/whats-wrong-with-delphis-widestring/
>
>
> Using the following example program and compiling with 'fpc -al
> wstest.pas'  under Linux to see the assembler file (not that I can
> remember anything of how assembler works). Looking at the asm code I
> see a call to FPC_WIDESTR_INCR_REF which I assume confirms that
> WideStrings under Linux using FPC is also reference counted.
>
> Is the same true under Windows?  Does that mean FPC doesn't have the
> WideString issues Delphi has?
>
Widestrings were reference counted on all platforms before FPC 2.2 . With 
version 2.2 FPC switched to the Delphi behaviour on Windows in order to 
achieve COM compatibility.
Cossplatform unicode applications like MSEide+MSEgui:
http://sourceforge.net/projects/mseide-msegui
suffer from the performance loss due to the non reference counted widestrings 
on Windows. MSEide+MSEgui is completely done with widestrings.
I suggest to introduce a new COM compatible OLE-string type and let 
widestrings be reference counted on all platforms.
It seems that CodeGear plans to go a similar route:
http://groups.google.ch/group/borland.public.delphi.non-technical/msg/7caeced42f1934a4?hl=en&
The introduced string handling for the "Unicode VCL" is equivalent to the 
string handling in MSEgui BTW.

Martin



More information about the fpc-devel mailing list