You must explicitly convert it to PChar :
SetString(result,PChar(@LCData),Length);
As you said, SetString() very picky about the second type of parameters. It must be either PChar or a PWideChar , or a PAnsiChar , depending on the type of string itself.
I suspect this is due to the fact that SetString() is defined as overloaded with either a string , a WideString , or AnsiString as the 1st parameter. Therefore, in order to verify the correct signature, it must have an exact correspondence of all types of parameters:
SetString(var s: string; buf: PChar; len: integer); overload; SetString(var s: AnsiString; buf: PAnsiChar; len: integer); overload; SetString(var s: WideString; buf: PWideChar; len: integer); overload;
Of course, all these are "intrinsics", so you will not find such a definition in system.pas, but directly any procedure like _LStrFromPCharLen() _UStrFromPCharLen() _WStrFromPWCharLen() or such.
This behavior occurs from earlier versions of Delphi and is not a regression in XE2.
source share