Results 1 to 5 of 5

Thread: Error: Illegal qualifier

  1. #1
    Co-Founder / PGD Elder WILL's Avatar
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    6,107
    Blog Entries
    25

    Error: Illegal qualifier

    I get the strangest error when I try running my project with this code in it. Thing is this code works in another project, it should be code independant. What am I not seeing?

    [pascal]procedure DrawTile(GameScreen: PSDL_Surface; X, Y, TileIndex, TileSize: Integer; TileSet: PSDL_Surface);
    var
    SrcRect, DestRect: TSDL_Rect;
    begin
    SrcRect := SDLRect(TileIndex * TileSize, 0, TileSize, TileSize);
    DestRect := SDLRect(X, Y, TileSize, TileSize);
    if ((X < GameScreen.w) or (X > -TileSize)) and ((Y < GameScreen.h) or (Y > -TileSize)) then
    SDL_BlitSurface(TileSet, @SrcRect, GameScreen, @DestRect);
    end;[/pascal]

    w and h are the Width and Height of the game screen.

    Here are the error messages I'm getting:

    Quote Originally Posted by Messages
    NightStalker2.lpr(359,26) Error: Illegal qualifier
    NightStalker2.lpr(359,26) Hint: may be pointer dereference is missing
    NightStalker2.lpr(359,13) Error: Operation "<" not supported for types "LongInt" and "PSDL_Surface"
    NightStalker2.lpr(359,26) Fatal: Syntax error, ")" expected but "identifier W" found
    oh FYI...
    [pascal]if ((X < GameScreen.w) or (X > -TileSize)) and ((Y < GameScreen.h) or (Y > -TileSize)) then[/pascal] is line 359.
    Jason McMillen
    Pascal Game Development
    Co-Founder





  2. #2

    Error: Illegal qualifier

    Every thing look's ok... if you are not using {$mode Delphi} then you must write code like this:
    Code:
    if &#40;&#40;X < GameScreen^.w&#41; or &#40;X > -TileSize&#41;&#41; and &#40;&#40;Y < GameScreen^.h&#41; or &#40;Y > -TileSize&#41;&#41;
    Maybe I'm wrong, but i think that FPC doesn't automaticly convert pointer types to non pointer types (PSDL_Surface to TSDL_Surface).

  3. #3
    Co-Founder / PGD Elder WILL's Avatar
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    6,107
    Blog Entries
    25

    Error: Illegal qualifier

    Well thats a possibility. It was a Delphi program moved to Lazarus so it may have something to do with the errors.

    The funniest thing though... I move this function form the main 'program' source to a unit and reference to it and all of a sudden, no errors. :?

    Interesting...


    Any ideas guys?
    Jason McMillen
    Pascal Game Development
    Co-Founder





  4. #4

    Error: Illegal qualifier

    Quote Originally Posted by Srki_82
    Maybe I'm wrong, but i think that FPC doesn't automaticly convert pointer types to non pointer types (PSDL_Surface to TSDL_Surface).
    You're 100% correct. In non-delphi modes you have to always explicitly dereference pointer.

    Why ? The long story is, AFAIK: Because in non-delphi modes you get other feature: Assuming that PMyType is a pointer to TMyType, and you have variable like MyTypePtr (of type PMyType), you can write things like
    MyTypePtr[100]
    and it will be treated like MyTypePtr was a pointer to an array of TMyType structures. In Delphi (or in FPC in delphi mode) to do the same thing you would have to declare some dummy type that is a pointer to an "inifite" array, like
    TMyTypeArray = array[0..MaxInt div SizeOf(TMyType)-1]of TMyType;
    PTMyTypeArray = ^TTMyTypeArray;
    and write
    PTMyTypeArray(MyTypePtr)[100]

    So in Delphi mode you get automatic dereferencing of pointers to arrays/records, and in non-delphi mode you get treating pointers as arrays (like in C). These two features together could in some cases produce ambiguous code, so you can get only one feature or the other, not both at once...

    Quote Originally Posted by WILL
    The funniest thing though... I move this function form the main 'program' source to a unit and reference to it and all of a sudden, no errors. Confused
    Most probably you're accidentaly compiling your unit in delphi mode, and program file in non-delphi (like objfpc) mode. Maybe you include in your unit some file that does {$mode delphi} ? To hunt this down you can compile your code with -vc option ("Show conditionals"), look there for messages like
    Macro defined: FPC_DELPHI
    or
    Macro defined: FPC_OBJFPC
    These indicate FPC $mode changes.

  5. #5
    Co-Founder / PGD Elder WILL's Avatar
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    6,107
    Blog Entries
    25

    Error: Illegal qualifier

    ah ha! Nice catch michalis.

    Found the culprit. [pascal]{$mode objfpc}{$H+}[/pascal]

    Lazarus likes sticking this at the start of every new unit and program it creates. I have overall Delphi compatability mode set under my project's compiler options, but obviously didn't even notice that this little line was in there.

    Thanks for the help guys. Seems I've been spoiled by the way Delphi simplifies pointers.
    Jason McMillen
    Pascal Game Development
    Co-Founder





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
  •