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

José Mejuto joshyfun at gmail.com
Thu Jun 9 14:29:41 CEST 2016


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 ?

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.

-- 




More information about the fpc-pascal mailing list