[fpc-pascal] Incompatible types: got "SYSTEM.PChar" expected "SYSTEM.PChar"

Sven Barth pascaldragon at googlemail.com
Thu Jun 9 14:39:10 CEST 2016


Am 09.06.2016 14:30 schrieb "José Mejuto" <joshyfun at gmail.com>:
>
> El 09/06/2016 a las 8:04, Sven Barth escribió:
>
>>> {$DEFINE THISDONTCOMPILE}
>>>   TConstRecord: TFirstRecord = (
>>>   {$IFDEF THISDONTCOMPILE}
>>>     Ident: TSomePcharArray[1]
>>>   {$ELSE}
>>>     Ident: @TSomePcharArray[1]
>>>   {$ENDIF}
>>>   );
>
>
>> One can only use untyped constants to initialize other constants or
>> variables in their declarations. The TsomePCharArray is a typed
>> constant, thus not suitable for assignments (a pointer to it's element
>> is however legal as you noticed).
>
>
> Hello,
>
> The strange thing is that if I use a pointer, an integer or any other
type instead a Pchar the error message is completely different "Error:
Can't read or write variables of this type" which is a bit more informative.
>
> I understand that untyped is the only source for assign a constant to so
using @ I get an untyped pointer and the assign is performed, but is there
a way to convert a pointer (typed) to untyped one ?

Typed and untyped pointer have nothing to do with this. It's about typed
and untyped constants. And addresses to variables and typed constants are
by definition untyped constants as well.

> I think that the solution is to pollute the symbol table with a lot of
consts, one of each text string.
>
> Thank you for your help and enlightenment.

You're welcome.

Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20160609/741252d1/attachment.html>


More information about the fpc-pascal mailing list