On Mon, 30 Nov 2020, Sven Barth via fpc-pascal wrote:
Am 30.11.2020 um 13:20 schrieb LacaK via fpc-pascal:
Hi,
is there a way how to initialize record member of pointer type (other
than PChar) in the following example:
type
TMyRec=record
a: PByte; // if I change PByte to PAnsiChar then it works
end;
const
MyConst: TMyRec = (a: 'abcd'); // I want to a points to static
memory where 'abcd' is stored
I would like to initialize a to be pointer to another known constant
or directly to supplied string constant.
For example something like:
const
MyConst1='abcd';
MyConst2=TMyRec = (a: @MyConst1);
Untyped constants don't have an address you can take. You need to use a
typed constant:
=== code begin ===
const
MyConst1: Byte = 123;
MyConst2: TMyRec = (a: @MyConst1);
Does this also work with variables ?
Might be worth writing in the documentation...
Michael.
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal