1
votes

We are using Delphi 10.3.2. with OSX64 support. We are developing a project on OSX64 that uses GCC compiled dylib. Dylib libraries on OSX64 by default are not stdcall or cdecl so we have to remove on all functions those directives. We have a problem with QueryInterface that we have to change from stdcall to nothing.

We tried creating our own class of MyIINterface and TMYInterfacedObject but it cannot compile since it returns error

E2211 Declaration of 'QueryInterface' differs from declaration in interface 'MyIInterface'
mycom.pas(10): Related member: function QueryInterface(const TGUID; out): HRESULT;

How is this possible? Also if we rename QueryInterface to QueryInterface2 in MyIINterface it still requires QueryInterface.

  type

  MyIInterface = interface
    ['{00000000-0000-0000-C000-000000000046}']
    function QueryInterface(const IID: TGUID; out Obj): HResult;
    function _AddRef: Integer; 
    function _Release: Integer;
  end;

  MyIUnknown = IInterface;

  TMyInterfacedObject = class(TObject, MyIInterface)
  protected

    function QueryInterface(const IID: TGUID; out Obj): HResult;
1
Calling conventions like stdcall and cdecl only apply to 32bit compilations, they are ignored on 64bit compilations. 64bit compilers automatically use the proper 64bit calling convention for the system being compiled for. So you don't need to remove the calling conventions from code declarations. Whatever problem you are experiencing is related to something else.Remy Lebeau

1 Answers

1
votes

The OSX64 compiler ignores calling convention declarations and uses the platform calling convention for all functions.

The change you are proposing has no effect on any generated code on this platform. However, this change will break your code if you ever come to compile on a platform where the calling convention does matter. You should therefore not make any such change as you propose.

Whatever your problem is, this is not the solution.