You are not logged in.
Pages: 1
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! ), 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
It was compiling fine with Delphi XE2 and XE3, on both 32 and 64 bit.
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
Pages: 1