[fpc-pascal] pointer to char vs pchar
Benito van der Zander
benito at benibela.de
Fri Mar 24 15:04:16 CET 2023
Hallo,
why is a pointer to a char not a pchar (for type helpers)?
program Project1;
{$Mode objfpc}{$H+} {$ModeSwitch typehelpers}
type TPcharHelper = type helper for pchar
function toString(length: integer): string;
end;
function TPcharHelper.toString(length: integer): string;
begin
SetString(result, self, length);
end;
var c: char;
begin
c := 'x';
writeln((@c).toString(1)); //does not compile
writeln(pchar(@c).toString(1));
end.
Bye,
Benito
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20230324/05d50e5a/attachment.htm>
More information about the fpc-pascal
mailing list