Page 2 of 4 FirstFirst 1234 LastLast
Results 11 to 20 of 31

Thread: Free Pascal 2.0

  1. #11

    Free Pascal 2.0

    It compiles and links fine on my Linux system.

    On Linux, everything compiles, but when it comes to the linking stage it says cannot find "-lSDL". Any ideas?
    Do you have an libSDL.so link in your /usr/lib or /usr/local/lib directory?

    On Win32 for another project it complains about mismatching types between POINT and TPoint but the same code compiles fine with Delphi 7 and used to compile with 1.9.8. Anyone know where POINT is defined in FPC?
    The Point function is declared in the classes unit. It returns a TPoint record, which is defined in the types unit, as so:

    Code:
    {$ifdef Win32}
      TPoint = Windows.TPoint;
    {$else}
      TPoint =
    {$ifndef FPC_REQUIRES_PROPER_ALIGNMENT}
      packed
    {$endif FPC_REQUIRES_PROPER_ALIGNMENT}
      record
        X : Longint;
        Y : Longint;
      end;
    [size=10px]"In science one tries to tell people, in such a way as to be understood by everyone, something that no one ever knew before. But in poetry, it's the exact opposite." -- Paul Dirac[/size]

  2. #12

    Free Pascal 2.0

    In the Win32 project, my uses clause looks like this...
    [pascal]
    interface

    uses
    sdl,
    SiegeInterfaces,
    AdventureLog;
    ...
    implementation

    uses
    {$IFDEF ver120}
    FileCtrl,
    {$ENDIF}
    Classes,
    SysUtils,
    logger,
    globals,
    GameMainMenu;
    [/pascal]

    and the procedure that causes the error looks like this...

    [pascal]
    procedure TGameJournal.MouseMove( Shift : TSDLMod; CurrentPos, RelativePos : TPoint );
    const
    FailName : string = 'TGameJournal.MouseMove';
    begin
    inherited;
    end;
    [/pascal]

    and when compiled it gives the following error...
    GameJournal.pas(247,24) Error: function header doesn't match any method of this
    class "TGameJournal.MouseMove(LongWord, POINT, POINT)"
    GameJournal.pas(251,12) Error: Incompatible type for arg no. 3: Got "POINT", exp
    ected "TPoint"
    What's seems to be happening is that the implemenation code is using the Classes definition of TPoint, while the interface declaration is using the sdl definition of TPoint. This never happened in 1.9.8. if I comment out the Classes unit ( which I need for TStringList ), everything compiles, but I get an immediate AV when I try to run the exe.

    Any suggestions?

    On the Linux side of things, I will double check to see if I have a libSDL.so around.
    <br /><br />There are a lot of people who are dead while they are still alive. I want to be alive until the day I die.<br />-= Paulo Coelho =-

  3. #13

    Free Pascal 2.0

    Use sdl.TPoint;

    Example:

    procedure DoSomething(a: sdl.TPoint);
    ...

    also in interface. This will clarify which TPoint is used and I think also cure the AV(IMHO it was caused by writing a Classes.TPoint into Sdl.TPoint which is much smaller)

    The missing -lSDL is defenetly missing libsdl.so. Make sure you have developmenet packages of SDL installed.
    Feel the power of Open Source.
    <br />Feel the power of Free Pascal.

  4. #14

    Free Pascal 2.0

    Umm i've recompiled one of my project with FPC 2 and it gives AV. With old versions it was running just fine. :?
    I'll indagate a little
    If you save your data in a proprietary format, the owner of the format owns your data.
    <br /><A href="http://msx80.blogspot.com">http://msx80.blogspot.com</A>

  5. #15

    Free Pascal 2.0

    Quote Originally Posted by Almindor
    Use sdl.TPoint;
    Sure this is a work around I tried already, but should not be necessary. As I mentioned , this code worked without errors with the v1.9.8 compiler. It should not be necessary because interface scoped references, in this case sdl.TPoint, should take precedence over implemenation scoped references like Classes.TPoint. At least, that is how it works in Delphi.

    Also as I already mentioned, if I remove Classes from the uses clause ( and the associated TStringList code ) it compiles, but I still get and AV on startup .

    It seems that MSX is having a similar problem with the AV.
    <br /><br />There are a lot of people who are dead while they are still alive. I want to be alive until the day I die.<br />-= Paulo Coelho =-

  6. #16

    Free Pascal 2.0

    I reproduced your error on my win32 machine with the following test project (and unit):

    testpoint.dpr:

    [pascal]program testpoint;

    uses
    SDL, testunit;

    var
    P: TPoint;
    begin
    P.X := 10;
    P.Y := 5;
    P := SwapXY(P);
    Writeln('P.X = ', P.X, ', P.Y = ', P.Y);
    end. [/pascal]

    testunit.pas:

    [pascal]unit testunit;

    interface

    uses
    SDL, Classes;

    function SwapXY(P: TPoint): TPoint;

    implementation

    function SwapXY(P: TPoint): TPoint;
    begin
    SwapXY.X := P.Y;
    SwapXY.Y := P.X;
    end;

    end.[/pascal]

    I will test on Linux later.
    [size=10px]&quot;In science one tries to tell people, in such a way as to be understood by everyone, something that no one ever knew before. But in poetry, it&#39;s the exact opposite.&quot; -- Paul Dirac[/size]

  7. #17

    Free Pascal 2.0

    Can this be passed on to the FreePascal guys?

    I still think that the order and scope of the definitions should determine which unit take precedence. Does others agree or not?
    <br /><br />There are a lot of people who are dead while they are still alive. I want to be alive until the day I die.<br />-= Paulo Coelho =-

  8. #18

    Free Pascal 2.0

    OK, I tested it on Linux and also reproduced the error.

    Interestingly, if you swap the order of SDL and Classes in the uses section of the testunit.pas unit file, then it compiles properly and uses the SDL.TPoint definition. Perhaps this is by design, I don't know. I can post this on the Free Pascal forum if you like, and see what they have to say about the matter. But we need someone with FPC v1.9.8 (or less) to test it using my source code above to verify that things have changed from v1.9.8 (or less) to v2.0.0.
    [size=10px]&quot;In science one tries to tell people, in such a way as to be understood by everyone, something that no one ever knew before. But in poetry, it&#39;s the exact opposite.&quot; -- Paul Dirac[/size]

  9. #19

    Free Pascal 2.0

    I have 1.9.8 on one of my other machines so will test you test app when I get home this evening.

    Are you having the same problem with the AV? I will be re-installing my Win32 installation of 2.0 to make sure that an old install isn't interfereing.
    <br /><br />There are a lot of people who are dead while they are still alive. I want to be alive until the day I die.<br />-= Paulo Coelho =-

  10. #20

    Free Pascal 2.0

    Here, I found this on page 107 (second-last paragraph) of the ref.pdf document that comes with FPC v2.0.0:

    The uses clause serves to identify all units that are needed by the program. The system unit doesn?¢_Tt have to be in this list, since it is always loaded by the compiler. The order in which the units appear is significant, it determines in which order they are initialized. Units are initialized in the same order as they appear in the uses clause. Identifiers are searched in the opposite order, i.e. when the compiler searches for an identifier, then it looks first in the last unit in the uses clause, then the last but one, and so on.
    This explains the behaviour we are seeing. In the source code above, when the compiler encounters TPoint in the testunit.pas file, it first looks in Classes, which is the last unit in the uses clause and where it finds the definition of TPoint, at which point it complains about incompatible types.

    I will look at my earlier versions of this document to see if it's different.
    [size=10px]&quot;In science one tries to tell people, in such a way as to be understood by everyone, something that no one ever knew before. But in poetry, it&#39;s the exact opposite.&quot; -- Paul Dirac[/size]

Page 2 of 4 FirstFirst 1234 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •