#1 2013-05-08 17:08:15

Geppy
Member
Registered: 2013-05-08
Posts: 6

Delphi 2010 compiler errors in mORMot.pas

Hi all,

first message here.
Today I downloaded the last sources and installed mORMot for the first time.
I'm using Delphi 2010 Pro but after following all instructions (unzip, library path, SQLite3*.obj files, etc.) I tried to compile the TestSQL3 project but I got an error.
I read the documentation (very good and complete! yikes), searched the forum, the blog, the code comments but I didn't find any help about this problem.

This is the code that causes the error:

{$ifdef ISDELPHI2010} // Delphi 2009 generics support is buggy :(
function TSQLRest.Service<T>: T;
var service: TServiceFactory;
begin
  service := fServices.Info(TypeInfo(T));
  if (service=nil) or not service.Get(result) then
    result := nil;
end;
{$endif}

Delphi says '[DCC Error] mORMot.pas(20736): E2010 Incompatible types: 'T' and 'Pointer', pointing to the line 'result := nil;'
I didn't define any strange complier directive on my own.
I tried also to compile without directive ISDELPHI2010 in Synopse.inc, but I got the same error.

Then I Googled a bit and I found on StackOverflow this answer.
So I changed
'result := nil;'
to
'result := Default(T);'
Now I can compile, run TestSQL3.exe and pass all the tests.

The question is: is it a safe change?
I don't use Generics in Delphi, so I'm pretty lost with the Generics incompatibility types error message.

Thank you in advance.

Last edited by Geppy (2013-05-08 17:08:59)

Offline

#2 2013-05-08 18:31:12

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

Re: Delphi 2010 compiler errors in mORMot.pas

It was compiling fine with Delphi XE2 and XE3, on both 32 and 64 bit.
sad

But you are right: Default(T) is to be used here.

Should be fixed by http://synopse.info/fossil/info/fb7d741ede

Thanks a lot for your report, including the solution!

Offline

Board footer

Powered by FluxBB