Defining a pure base class using IDL

When I define an interface in IDL that doesn't come from anything, the MIDL precompiler warns as such (Visual C ++ 2008):
  MIDL2271 warning: [object] interfaces must be derived from another [object] interface such as IUnknown (. ..)

And if I get my interface from another that is not derived from IUnknown, the MIDL fails:
  MIDL2257 error: Only the IUnknown interface can be used as the root interface (...)

Now, my question is, is this a limitation in COM or the MIDL precompiler?

I was looking at the D3D10 headers recently and d3d10.h was apparently generated using IDL (MIDL adds a comment to this effect). And all interfaces derive from IUnknown in one way or another.

However, the peripheral headers (d3d10shader.h, d3d10effect.h, etc.) contain manually defined COM interfaces, some of which throw a warning or the error described here. I can only assume that they had to define them manually to avoid these limitations.

I'm right? Why does MIDL prevent clean interfaces?

+1


source to share


1 answer


An interface that is not derived from IUnknown is not COM. It is the main building block that allows memory management and interface detection.



There may be interfaces that are not related to IUnknown. However, these are not COM, they are just a normal pointer.

+1


source







All Articles