Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2010-02

can't take the address of constant expressions

10 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Roberto Padovani

with lazarus 0.9.28.x I get the error in the subject, while compiling the packages "cmdline" and "plotpanel" (downloaded from CCR) They were working, before my recent troubles with the packages and the installation of the .2 and .3 (daily) lazarus versions.

The error messages are:
C:\lazarus\extras\cmdline-0.5.2\cmdline\ucmdbox.pas(1834,32) Error: Can't take the address of constant expressions
and
C:\lazarus\extras\plotpanel_lazarus_0.96\plotpanel.pas(658,54) Error: Can't take the address of constant expressions
C:\lazarus\extras\plotpanel_lazarus_0.96\plotpanel.pas(771,52) Error: Can't take the address of constant expressions
C:\lazarus\extras\plotpanel_lazarus_0.96\plotpanel.pas(828,51) Error: Can't take the address of constant expressions
C:\lazarus\extras\plotpanel_lazarus_0.96\plotpanel.pas(864,52) Error: Can't take the address of constant expressions

in my opinion there are no constant expressions there.

Thanks,

Roberto

Reply by email

Flávio Etrusco
to Roberto Padovani

Err, it would useful for you to post the source code in question. I guess these are errors are caused by object properties?...

-Fl?vio

Roberto Padovani wrote 30 lines
with lazarus 0.9.28.x I get the error in the subject, while compiling the packages "cmdline" and "plotpanel" (downloaded from CCR) They were working, before my recent troubles with the packages and the installation of the .2 and .3 (daily) lazarus versions. The error messages are: C:\lazarus\extras\cmdline-0.5.2\cmdline\ucmdbox.pas(1834,32) Error: Can't take the address of constant expressions and C:\lazarus\extras\plotpanel_lazarus_0.96\plotpanel.pas(658,54) Error: Can't take the address of constant expressions C:\lazarus\extras\plotpanel_lazarus_0.96\plotpanel.pas(771,52) Error: Can't take the address of constant expressions C:\lazarus\extras\plotpanel_lazarus_0.96\plotpanel.pas(828,51) Error: Can't take the address of constant expressions C:\lazarus\extras\plotpanel_lazarus_0.96\plotpanel.pas(864,52) Error: Can't take the address of constant expressions in my opinion there are no constant expressions there. Thanks, ?Roberto -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

Roberto Padovani
to Flávio Etrusco

2010/2/5 Fl?vio Etrusco :

Err, it would useful for you to post the source code in question. I guess these are errors are caused by object properties?...

I did not post them because the files are available on the Lazarus CCR. However here is the error in the package "cmdline":

Offending instruction:              Inc(InputPos, UTF8Length(s));
where the parameters are defined as:
s: WideString;          // a local variable in the method
property InputPos: integer Read FInputPos;          // a class
property with the correspondig private FInputPos:  integer;

Roberto

Reply by email

Flávio Etrusco
to Roberto Padovani

That's it.
That code used to compile with FPC 2.2, but doesn't with 2.4. See: http://wiki.freepascal.org/User_Changes_2.4.0#Treating_direct-mapped_properties_as_regular_fields In this case, simply change the code to "Inc(FInputPos, UTF8Length(s));".

Best regards,
Fl?vio

Roberto Padovani wrote 23 lines
2010/2/5 Fl?vio Etrusco : > Err, it would useful for you to post the source code in question. I > guess these are errors are caused by object properties?... > I did not post them because the files are available on the Lazarus CCR. However here is the error in the package "cmdline": Offending instruction: ? ? ? ? ? ? ?Inc(InputPos, UTF8Length(s)); where the parameters are defined as: s: WideString; ? ? ? ? ?// a local variable in the method property InputPos: integer Read FInputPos; ? ? ? ? ?// a class property with the correspondig private FInputPos: ?integer; Roberto -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

Roberto Padovani
to Flávio Etrusco

Ok, thanks!
I'll patch the files on my PC, but maintainers of the components "Plot Panel" and "CmdLine" should be alerted on this.

Roberto

2010/2/5 Fl?vio Etrusco :

Show quoted text 39 lines
That's it. That code used to compile with FPC 2.2, but doesn't with 2.4. See: http://wiki.freepascal.org/User_Changes_2.4.0#Treating_direct-mapped_properties_as_regular_fields In this case, simply change the code to "Inc(FInputPos, UTF8Length(s));". Best regards, Fl?vio On Fri, Feb 5, 2010 at 12:07 PM, Roberto Padovani wrote: > 2010/2/5 Fl?vio Etrusco : >> Err, it would useful for you to post the source code in question. I >> guess these are errors are caused by object properties?... >> > > I did not post them because the files are available on the Lazarus CCR. > However here is the error in the package "cmdline": > > Offending instruction: ? ? ? ? ? ? ?Inc(InputPos, UTF8Length(s)); > > where the parameters are defined as: > s: WideString; ? ? ? ? ?// a local variable in the method > property InputPos: integer Read FInputPos; ? ? ? ? ?// a class > property with the correspondig private FInputPos: ?integer; > > Roberto > > -- > _______________________________________________ > Lazarus mailing list > > http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus > -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

Roberto Padovani
to Flávio Etrusco: That's it. That code used to compile with FPC 2.2, but doesn't with 2.4. See:…

2010/2/5 Fl?vio Etrusco :

Show quoted text 8 lines
That's it. That code used to compile with FPC 2.2, but doesn't with 2.4. See: http://wiki.freepascal.org/User_Changes_2.4.0#Treating_direct-mapped_properties_as_regular_fields In this case, simply change the code to "Inc(FInputPos, UTF8Length(s));". Best regards, Fl?vio

In this case, I can't understand why the error is gine in plotpanel package for the following line:

    FOnXMarksWrite(self,X,xStr,ACanvas.Font,evtHandled);

which is inside the implementation of

    procedure TPlotPanel.WriteXaxisValues(ACanvas:TCanvas);
    var
       X : Extended;
       XStr : string;
       evtHandled : Boolean;
    ...

isn't it right to read the ACanvas.Font property?
In fact, I can't change it to the FFont private variable, because they belong to different classes.

Roberto

Reply by email

Flávio Etrusco
to Roberto Padovani
Show quoted text 21 lines
In this case, I can't understand why the error is gine in plotpanel package for the following line: ? ?FOnXMarksWrite(self,X,xStr,ACanvas.Font,evtHandled); which is inside the implementation of ? ?procedure TPlotPanel.WriteXaxisValues(ACanvas:TCanvas); ? ?var ? ? ? X : Extended; ? ? ? XStr : string; ? ? ? evtHandled : Boolean; ? ?... isn't it right to read the ACanvas.Font property? In fact, I can't change it to the FFont private variable, because they belong to different classes. Roberto

What's the signature of FOnXMarksWrite method/handler?

-Fl?vio

Reply by email

Roberto Padovani
to Flávio Etrusco

2010/2/5 Fl?vio Etrusco :

Show quoted text 25 lines
> > In this case, I can't understand why the error is gine in plotpanel > package for the following line: > > ? ?FOnXMarksWrite(self,X,xStr,ACanvas.Font,evtHandled); > > which is inside the implementation of > > ? ?procedure TPlotPanel.WriteXaxisValues(ACanvas:TCanvas); > ? ?var > ? ? ? X : Extended; > ? ? ? XStr : string; > ? ? ? evtHandled : Boolean; > ? ?... > > isn't it right to read the ACanvas.Font property? > In fact, I can't change it to the FFont private variable, because they > belong to different classes. > > Roberto > What's the signature of FOnXMarksWrite method/handler? -Fl?vio
private
    FOnXMarksWrite: TWriteAxisEvt;  // X Axis draw event
    FOnYMarksWrite: TWriteAxisEvt;  // Y Axis draw event

which refers to:

TWriteAxisEvt = procedure(Sender: TCustomPanel; Value:extended;var AxisText:String; var AxisFont:TFont; var EventHandled:boolean) of object;

bye,

Roberto

Show quoted text 7 lines
-- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

Flávio Etrusco
to Roberto Padovani

So there you go. The parameter is passed as 'var', which implies knowing the variable address. I doubt there's a valid reason for this, so the fix would be to remove the 'var' modifier.

[]s

Roberto Padovani wrote 58 lines
2010/2/5 Fl?vio Etrusco : >> >> In this case, I can't understand why the error is gine in plotpanel >> package for the following line: >> >> ? ?FOnXMarksWrite(self,X,xStr,ACanvas.Font,evtHandled); >> >> which is inside the implementation of >> >> ? ?procedure TPlotPanel.WriteXaxisValues(ACanvas:TCanvas); >> ? ?var >> ? ? ? X : Extended; >> ? ? ? XStr : string; >> ? ? ? evtHandled : Boolean; >> ? ?... >> >> isn't it right to read the ACanvas.Font property? >> In fact, I can't change it to the FFont private variable, because they >> belong to different classes. >> >> Roberto >> > > What's the signature of FOnXMarksWrite method/handler? > > -Fl?vio private ? ?FOnXMarksWrite: TWriteAxisEvt; ?// X Axis draw event ? ?FOnYMarksWrite: TWriteAxisEvt; ?// Y Axis draw event which refers to: TWriteAxisEvt = procedure(Sender: TCustomPanel; Value:extended;var AxisText:String; var AxisFont:TFont; var EventHandled:boolean) of object; bye, Roberto > > -- > _______________________________________________ > Lazarus mailing list > > http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus > -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

Roberto Padovani
to Flávio Etrusco

2010/2/5 Fl?vio Etrusco :

So there you go. The parameter is passed as 'var', which implies knowing the variable address. I doubt there's a valid reason for this, so the fix would be to remove the 'var' modifier.

Thanks, that fixed it.

Roberto

Show quoted text 68 lines
[]s On Fri, Feb 5, 2010 at 2:32 PM, Roberto Padovani wrote: > 2010/2/5 Fl?vio Etrusco : >>> >>> In this case, I can't understand why the error is gine in plotpanel >>> package for the following line: >>> >>> ? ?FOnXMarksWrite(self,X,xStr,ACanvas.Font,evtHandled); >>> >>> which is inside the implementation of >>> >>> ? ?procedure TPlotPanel.WriteXaxisValues(ACanvas:TCanvas); >>> ? ?var >>> ? ? ? X : Extended; >>> ? ? ? XStr : string; >>> ? ? ? evtHandled : Boolean; >>> ? ?... >>> >>> isn't it right to read the ACanvas.Font property? >>> In fact, I can't change it to the FFont private variable, because they >>> belong to different classes. >>> >>> Roberto >>> >> >> What's the signature of FOnXMarksWrite method/handler? >> >> -Fl?vio > > > private > ? ?FOnXMarksWrite: TWriteAxisEvt; ?// X Axis draw event > ? ?FOnYMarksWrite: TWriteAxisEvt; ?// Y Axis draw event > > which refers to: > > TWriteAxisEvt = procedure(Sender: TCustomPanel; Value:extended;var > AxisText:String; var AxisFont:TFont; var EventHandled:boolean) of > object; > > bye, > > Roberto > > > >> >> -- >> _______________________________________________ >> Lazarus mailing list >> >> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus >> > > -- > _______________________________________________ > Lazarus mailing list > > http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus > -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email