2

Are there no constant references in MIDL method declarations????

eg.

[id(1), helpstring("My Method")]
HRESULT MyMethod(
    [in] IID & const rclsid
);

for

HRESULT MyMethod(
    IID const &rclsid
);
Paul R
  • 208,748
  • 37
  • 389
  • 560
  • d3d11.idl uses REFGUID :/ I don't know how to feel about this o~o rather good I guess 'cause it works; question still stands though 'cause I don't see how REFGUID is even possible if you can't and yet I can't seem to nor find an example...... –  Jun 12 '10 at 09:03
  • What did Paul change?? Did I use an is instead of an are??? I do that sometimes... –  Jun 12 '10 at 18:14

1 Answers1

2

MIDL doesn't really support reference parameters, it only supports "in" and "out" parameters. So if you DO pass in a reference, it's just syntactic sugar for a pointer to the value (the issue is observability - if you have a callback function or interface in our method signature, changes to a reference would be observable from the callback, but changes to an [out] parameter aren't visible until the function returns.

In addition, the difference between "& const" and "const &" are lost. If you look at the definition of REFGUID, you'll see that they only use one form of "const" for C++ code:

#ifdef __midl_proxy
#define __MIDL_CONST
#else
#define __MIDL_CONST const
#endif

#ifndef _REFGUID_DEFINED
#define _REFGUID_DEFINED
#ifdef __cplusplus
#define REFGUID const GUID &
#else
#define REFGUID const GUID * __MIDL_CONST
#endif
#endif
Larry Osterman
  • 16,086
  • 32
  • 60