Sign in Join

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

Mailing lists / fpc-pascal / 2009-03

Incompatible types: got "Extended" expected "SmallInt"

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

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

Joseph Montanez

Im not sure why its giving me this error, as its pointing right at the plus signs

G3DPrimatives.pas(34,43) Error: Incompatible types: got "Extended"
expected "SmallInt"
G3DPrimatives.pas(36,43) Error: Incompatible types: got "Extended"
expected "SmallInt"
      2 : Index := Y * Surface^.pitch / 2 + X;
                                                       ^
23  procedure DrawPixel(var Surface : PSDL_Surface; X, Y, R, G, B : integer);
24  var
25    Color : longword;
26    Pixel : ^longword;
27    Index : integer;
28  begin
29    New(Pixel);
30    case Surface^.format^.BytesPerPixel of
31      {8bpp}
32      1 : Index := Y * Surface^.pitch + X;
33      {16bpp}
34      2 : Index := Y * Surface^.pitch / 2 + X;
35      {32bpp}
36      4 : Index := Y * Surface^.pitch / 4 + X;
37    else
38      WriteLn('Unsupported byte per pixel');
39    end;
40    Pixel := Surface^.pixels + Index;
41    Color := SDL_MapRGB(Surface^.format, R, G, B);
42    Pixel^:= Color;
43  end;
David Emerson
to Joseph Montanez

because the '/' operator does not return an integer. Use div if you want an integer result.

Cheers,
David.

Joseph Montanez wrote 11 lines
Im not sure why its giving me this error, as its pointing right at the plus signs G3DPrimatives.pas(34,43) Error: Incompatible types: got "Extended" expected "SmallInt" G3DPrimatives.pas(36,43) Error: Incompatible types: got "Extended" expected "SmallInt" 2 : Index := Y * Surface^.pitch / 2 + X; ^ 23 procedure DrawPixel(var Surface : PSDL_Surface; X, Y, R, G, B :
integer);
Show quoted text 21 lines
24 var 25 Color : longword; 26 Pixel : ^longword; 27 Index : integer; 28 begin 29 New(Pixel); 30 case Surface^.format^.BytesPerPixel of 31 {8bpp} 32 1 : Index := Y * Surface^.pitch + X; 33 {16bpp} 34 2 : Index := Y * Surface^.pitch / 2 + X; 35 {32bpp} 36 4 : Index := Y * Surface^.pitch / 4 + X; 37 else 38 WriteLn('Unsupported byte per pixel'); 39 end; 40 Pixel := Surface^.pixels + Index; 41 Color := SDL_MapRGB(Surface^.format, R, G, B); 42 Pixel^:= Color; 43 end; __________________________