[fpc-pascal]force ansistrings to be copied on duplication

Marc Santhoff M.Santhoff at t-online.de
Thu Jul 29 06:33:42 CEST 2004


Hi,

according to the manual AnsiStrings are 'copied on change'.

Can the compiler be forced to copy on duplication?

--- like this ---
var
  s1:PChar='something';
  s2:PChar;

begin
  s2 := s1;
  if (s1 <> s2) then
    writeln('Okay')
  else
    writeln(':-( only a doubled pointer');

end;

---

As an alternative I think I would have to use StrNew/StrDispose and do
some pointer collection. That would be too much effort in my case...

TIA,
Marc






More information about the fpc-pascal mailing list