Am 09.06.2016 00:05 schrieb "José Mejuto" <joshy...@gmail.com>: > ----------------------- > program testpossiblebug; > > type > TFirstRecord=record > Ident: pchar; > end; > > const > TSomePcharArray: array [0..1] of pchar = ( 'pcharONE','pcharTWO'); > > {$DEFINE THISDONTCOMPILE} > > TConstRecord: TFirstRecord = ( > {$IFDEF THISDONTCOMPILE} > Ident: TSomePcharArray[1] > {$ELSE} > Ident: @TSomePcharArray[1] > {$ENDIF} > ); > > var > R: TFirstRecord; > > begin > R:=TConstRecord; > {$IFDEF THISDONTCOMPILE} > writeln(R.Ident); > {$ELSE} > writeln(PPchar(R.Ident)^); > {$ENDIF} > end. > ------------------------ > > This does not compile and outputs the funny error in the subject. I think it should compile as information is static and previously defined, but if it is indeed an error by my side maybe the error message should be a bit different :-? > > To test the example, define or undefine the "THISDONTCOMPILE", with it defined it does not compile, without it it compiles and the modified writeln shows the expected pchar string. > > Should I report it ?
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). Don't know how easy it would be to print a better error message... Regards, Sven
_______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal