[fpc-devel] constref in Windows

José Mejuto joshyfun at gmail.com
Fri Nov 19 12:39:19 CET 2010


Hello FPC,

In fpc 2.5.1 trunk today the QueryInterface in rtl\inc\objpash.inc is
defined as:

IUnknown = interface
  ['{00000000-0000-0000-C000-000000000046}']
  function QueryInterface({$IFDEF FPC_HAS_CONSTREF}constref{$ELSE}const{$ENDIF} iid : tguid;out obj) : longint;{$IFNDEF WINDOWS}cdecl{$ELSE}stdcall{$ENDIF};
  function _AddRef : longint;{$IFNDEF WINDOWS}cdecl{$ELSE}stdcall{$ENDIF};
  function _Release : longint;{$IFNDEF WINDOWS}cdecl{$ELSE}stdcall{$ENDIF};
end;
IInterface = IUnknown;

Which after the resolved ifdefs it is compiled in Windows as:

IUnknown = interface
  ['{00000000-0000-0000-C000-000000000046}']
  function QueryInterface(constref iid : tguid;out obj) : longint; stdcall;
  function _AddRef : longint; stdcall;
  function _Release : longint; stdcall;
end;
IInterface = IUnknown;

Which breaks the compilation of source code like Zeos which expect the
"iid: tguid" to be const, not constref.

I'm aware about the changes done to be XPCOM compatible, but at the
price of "breaking" all existing COM code ? OK, the break is quite
easy to solve, just replace const by contref, but the question is...
Is needed to change it to constref in Windows platform too ?

I know Joost do the changes, but I think direct email is not a good
choice unless no answer in list of course.

-- 
Best regards,
 José




More information about the fpc-devel mailing list