0

My question is: what is the correct usage of the version tag in an IDL file that defines COM interfaces and classes and enums?

The MSN documentation of it is confusing: the first paragraph under "Remarks" seems to clearly say that the IID must be changed if anything changes in the interface.

But the rest of the page goes on to describe using differing versions with the same IID. There is even one of the sample COM interface pages that shows using version with interface.

What's going on?

Additional question: is it permitted to use version with an enum ? MIDL 7.00.05555 accepts the version attribute for enum, however if a versioned enum is used as a function parameter, MIDL gives an error.

M.M
  • 138,810
  • 21
  • 208
  • 365
  • `[version]` attribute can't be used with a COM interface, only RPC interface. The very article you cite says so: "The MIDL compiler does not support multiple versions of a COM interface. As a result, an interface attribute list that includes the `[object]` attribute cannot include the `[version]` attribute." In the second article you cite, the only instance of `[version]` applies to `library`, not to `interface`. – Igor Tandetnik Jul 28 '14 at 22:52
  • @IgorTandetnik So the entire "Remarks" section after the first paragraph is wrong? (I'm assuming that a "MIDL specification" is only relevant to COM interfaces) – M.M Jul 28 '14 at 22:54
  • MIDL is used both for COM and [DCE-RPC](http://en.wikipedia.org/wiki/DCE/RPC) interfaces (to the extent anyone actually uses the latter). – Igor Tandetnik Jul 28 '14 at 22:56
  • @IgorTandentik OK, so I should read "Remarks" para 1 as being about COM, and the rest of the page as about DCE-RPC. Write up an answer and I'll accept :) – M.M Jul 28 '14 at 23:06

1 Answers1

2

[version] attribute applies to DCE-RPC interfaces, not to COM interfaces (MIDL compiler supports both). Witness two quotes from the first article you cite:

The [version] interface attribute identifies a particular version among multiple versions of an RPC interface. (emphasis mine)

The MIDL compiler does not support multiple versions of a COM interface. As a result, an interface attribute list that includes the [object] attribute cannot include the [version] attribute.

In COM programming, the only useful place you could apply a [version] attribute is on a library clause. Type libraries support versioning.

Community
  • 1
  • 1
Igor Tandetnik
  • 50,461
  • 4
  • 56
  • 85