#1 2018-02-03 07:18:44

msgendodoc@gmail.com
Member
Registered: 2018-01-28
Posts: 15

Re: mORMot Sample 26 compiles in Delphi 10.1 not on Lazarus 1.8

Hi All

I'm a newbie trying to understand the mORMot framework.   Working with Sample 26 - the RESTful sever and client.   

In RestServerClass.pas on ln 69 I get an error

procedure TNoteServer.Blob(Ctxt: TSQLRestServerURIContext);
var AFileName: TFileName;
begin
  if (Ctxt.Table = TSQLNoteFile) and (Ctxt.TableID<>0) then
  begin
    AFileName := fBlobFolder+UTF8ToString(OneFieldValue(TSQLNoteFile,'FileName',Ctxt.TableID));
    case Ctxt.Method of
    mGET:
      Ctxt.ReturnFile(AFileName);
    mPOST,mPUT:
      begin
      FileFromString(Ctxt.Call.InBody, AFileName);          // ln 69: MG  Ctxt.Call.InBody is an ""Illegal qualifier" error in Lazarus - why?  Its OK in Delphi
      Ctxt.Success;
    end;
    mDELETE:
      if DeleteFile(AFileName) then
        Ctxt.Success else
        Ctxt.Error('',HTTP_NOTFOUND);
    end;
  end;
end;                     

// ln 69: MG  Ctxt.Call.InBody is an ""Illegal qualifier" error in Lazarus - why?  Its OK in Delphi
I think I understand that this code is retrieving a filename from the ORM data table and if the HTTP request is an mPOST or mPUT then trying to save the BLOB data to file. 
InBody is the REST request's content presumably.   Please advise if this is the case and also why the error.  This code works in Delphi 10.1.2

Many thanks

Martin

Offline

#2 2018-02-03 11:20:37

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,659
Website

Re: Re: mORMot Sample 26 compiles in Delphi 10.1 not on Lazarus 1.8

This is the default FPC behavior: pointers to records should explicitly be dereferenced via ^ whereas Delphi is more relax about it.
See e.g. http://forum.lazarus.freepascal.org/ind … pic=9521.0
You have to enable the "delphi mode" of FPC compilation, by using conditionals.

The easiest is to add in the beginning of all your units:

 {$I Synopse.inc} // define HASINLINE and some FPC-specific options

See https://synopse.info/fossil/info/a6b5db4365

Offline

#3 2018-02-03 12:18:15

msgendodoc@gmail.com
Member
Registered: 2018-01-28
Posts: 15

Re: Re: mORMot Sample 26 compiles in Delphi 10.1 not on Lazarus 1.8

Thx Arnaud,

Including the Synopse.inc declaration (and also adding that file's path to the project options include files path) fixed it, so now the project compiles. 

Or equally making an explicit pointer declaration for the InBody field

 FileFromString(Ctxt.Call^.InBody, AFileName);   //  changed from FileFromString(Ctxt.Call.InBody, AFileName); 

also worked. 

Many thanks Arnaud

Martin

Offline

Board footer

Powered by FluxBB