Sign in Join

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

Mailing lists / fpc-devel / 2007-05

Error: Argument can't be assigned to

3 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

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

Graeme Geldenhuys

Hi,

I thought I would try out FPC 2.3.1 (Revision: 7448) and compile fpGUI. Compiling fpGUI with 2.0.5 and 2.1.3 works 100%

Compiling it with FPC 2.3.1 (Revision: 7448) using

ppc386 -S2cgi -OG1 -gl -vewnhi -l -Fu../ -Fu. -FUlib/i386-linux/ fpgfxpackage.pas

..I get the following errors. Any ideas why?

fpGUI/gfx/x11/gfx_x11.pas(798,8) Error: Argument can't be assigned to
--------- code where error occurs  ---------------
  case Attr.Depth of
    1: PixelFormat.FormatType := ftMono;    //  <-- line 798
    4: PixelFormat.FormatType := ftPal4;
    8: PixelFormat.FormatType := ftPal8;
    16: PixelFormat.FormatType := ftRGB16;
    24: PixelFormat.FormatType := ftRGB24;
    32: PixelFormat.FormatType := ftRGB32;
    else
      raise EX11Error.CreateFmt(SWindowUnsupportedPixelFormat, [Attr.Depth]);
  end;

------------------ end -------------------------

PixelFormat and FormatType are defined as follows....

// PixelFormat instance is defined here
TFCustomCanvas = (TObject)
....
public
    property    PixelFormat: TGfxPixelFormat read FPixelFormat;
...
end;
  TGfxImageType = (
    ftInvalid,
    ftMono,		// Monochrome
    ftPal4,		// 4 bpp using palette
    ftPal4A,		// 4 bpp using palette with alpha values > 0
    ftPal8,		// 8 bpp using palette
    ftPal8A,		// 8 bpp using palette with alpha values > 0
    ftRGB16,		// 15/16 bpp RGB
    ftRGBA16,		// 16 bpp RGBA
    ftRGB24,		// 24 bpp RGB
    ftRGB32,		// 32 bpp RGB
    ftRGBA32);	        // 32 bpp RGBA
  TGfxPixelFormat = record
    FormatType: TGfxImageType;
    RedMask: TGfxPixel;
    GreenMask: TGfxPixel;
    BlueMask: TGfxPixel;
    AlphaMask: TGfxPixel;
  end;
Graeme Geldenhuys General error, hit any user to continue.

Reply by email

Jonas Maebe
to Graeme Geldenhuys
Graeme Geldenhuys wrote 8 lines
Compiling it with FPC 2.3.1 (Revision: 7448) using ppc386 -S2cgi -OG1 -gl -vewnhi -l -Fu../ -Fu. -FUlib/i386-linux/ fpgfxpackage.pas ..I get the following errors. Any ideas why? fpGUI/gfx/x11/gfx_x11.pas(798,8) Error: Argument can't be assigned to

****

From:
Subject: Re: [fpc-pascal] Release of fpc-2.1.4 aka 2.2.0-beta Date: 20 mei 2007 16:43:34 GMT+02:00
To:
Reply-To:

bartek wrote 21 lines
OK. And what about this: -----8<----- /home/bartek/Dev/units/glgui/glgui.pp(376,33) Error: Can't take the address of constant expressions -----8<----- constructor TGLGUI3DMouseMapper.Create(aOwnerDesktop: TGLGUIDesktop); begin OwnerDesktop:=aOwnerDesktop; OwnerDesktop.MouseMapper:=self; // 376 is here end; -----8<----- Definition snippet: -----8<----- // properties property OwnerDesktop: TGLGUIDesktop read fOwnerDesktop write fOwnerDesktop; -----8<-----

You cannot write to fields of properties. The reason is that any property accessor should be transparently replaceable by a function call, and if you do that in the above expression then your assignment would change something inside the (temporary) function result rather than in the field.

Jonas
***

Reply by email

Micha Nelissen
to Graeme Geldenhuys: I thought I would try out FPC 2.3.1 (Revision: 7448) and compile fpGUI. Compiling fpGUI…
Graeme Geldenhuys wrote 6 lines
--------- code where error occurs --------------- case Attr.Depth of 1: PixelFormat.FormatType := ftMono; // <-- line 798 4: PixelFormat.FormatType := ftPal4; public property PixelFormat: TGfxPixelFormat read FPixelFormat;

You only allow read access to a field, and you think it's strange the compiler doesn't allow writing ? :-).

Furthermore, using properties as reference (which includes writing to a field of it) is not allowed anymore. Either export a pointer, make the field itself public (and remove the property), or write the complete record.

Micha

Reply by email