Strange behavior

yvad yannurov at gmail.com
Tue Mar 25 00:22:46 PDT 2008


I have 2 modules.

// IUnknown.d
module IUnknown;
pragma(lib, "ole32.lib");

public import HRESULT;

extern (C) {
	const GUID IID_IUnknown;
}

extern (Windows) {
	interface IUnknown {
		HRESULT QueryInterface(in GUID* riid, out void* ppvObject);
		uint AddRef();
		uint Release();
	}
}

abstract class AbstractUnknown : IUnknown {

	extern (Windows):
	// IUnknown
	HRESULT QueryInterface(GUID* riid, out void* ppvObject);
	uint AddRef() {
             ....
	}
	uint Release() {
             ....
	}
}

// and  IClassFactory.d
module win32.api.com.interfaces.IClassFactory;
pragma(lib, "ole32.lib");

public import IUnknown;

extern (C) {
	const GUID IID_IClassFactory;
}

extern (Windows) {
	interface IClassFactory : IUnknown {
		HRESULT CreateInstance(in IUnknown pUnknown, in GUID* riid, out void* ppvObject);
		HRESULT LockServer(in bool fLock);
	}
}

abstract class AbstractClassFactory : AbstractUnknown, IClassFactory {

	extern (Windows):
	// IUnknown
	HRESULT QueryInterface(in GUID* riid, out void* ppvObject) {
             ....
	}

        ....
}

And I get an error on line in AbstractClassFactory "HRESULT QueryInterface(in GUID* riid, out void* ppvObject) {":
Severity and Description    Path    Resource    Location    Creation Time    Id
QueryInterface of type HRESULTWindows (GUID * riidriid, out void* ppvObject ppvObject) overrides but is not covariant with QueryInterface of type HRESULT(GUID * riidriid, void* ppvObject ppvObject)    import/win32/api/com/interfaces    IClassFactory.d    line 28    1206420149328    12010

if I comment line in AbstractUnknown with "HRESULT QueryInterface(in GUID* riid, out void* ppvObject);" it compiles without any error.
Is it should be so or I am doing something wrong?


More information about the Digitalmars-d-bugs mailing list