[fpc-devel] Variable can not be initialized by named constant

Jonas Maebe jonas.maebe at elis.ugent.be
Sun Mar 1 15:47:24 CET 2009


On 01 Mar 2009, at 15:29, Alexander Klenin wrote:

> I think this is quite reasonable to expect this to work.
> The writeability of constants is IMNSHO just an ugly leftover from
> Delphi history,
> and should be disabled in _both_ delphi and objfpc modes:
>
> {$IFDEF FPC}{$MODE DELPHI}{$ENDIF}
> const x: integer = 1;
> begin
> x := 3;
> end.
>
> Is rejected by Delphi, but compiled by FPC, which is a compatibility
> bug in itself.

This depends on a mode switch. Use {$j-} to turn off the ability to  
write to typed constants. Maybe it's off by default in your version of  
Delphi.

> So how about re-submitting the issue as a feature request?

You can try, but I'm afraid it'll stay open for quite a long time if  
no one also submits a patch.


Jonas



More information about the fpc-devel mailing list