[fpc-pascal] "Error: Impossible operator overload" ...why?

Graeme Geldenhuys graemeg.lists at gmail.com
Thu Sep 16 11:26:39 CEST 2010


Hi,

I'm using FPC 2.4.3

Why is the following operator overload not allowed?  Sometimes
TfpgColor can be a RRGGBB value (eg: clRed), and sometimes it is an
index to a color palette (eg: clWindowBackground).  So I want to do
comparisons between two such colors.

The compiler error I get:

..../programming/fpgui/src/corelib/fpg_main.pas(414,58) Error:
Impossible operator overload

The types are defined as follows:

type
  TfpgColor = type longword;

  TFPColor = record
    Red: word;
    Green: word;
    Blue: word;
    Alpha: word;
  end;


... now the unit with the compiler error ...


interface section:

  operator = (const AColor1, AColor2: TfpgColor) b: Boolean;


implementation section:

operator = (const AColor1, AColor2: TfpgColor) b: Boolean;
var
  c1, c2: TFPColor;
begin
  c1  := fpgColorToFPColor(AColor1);
  c2  := fpgColorToFPColor(AColor2);
  b   := (c1.Red = c2.Red) and (c1.Green = c2.Green) and
         (c1.Blue = c2.Blue) and (c1.Alpha = c2.Alpha);
end;




-- 
Regards,
  - Graeme -


_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/



More information about the fpc-pascal mailing list