I am trying to update an existing COM API to include a new optional output parameter, and am encountering a problem with forcing parameter types in the IDL file and its associated C ++ header file.
I used to have an IDL file like this (names changed to protect the innocent):
HRESULT CreateSomething(
[in] BSTR base_uri,
[in] ISomethingDescription* something_description,
[out, retval] BSTR* something_uri
);
and the corresponding C ++ header looked like this:
HRESULT __stdcall CreateSomething(
BSTR study_uri,
ISomethingDescription* something_description,
BSTR* something_uri
);
This needed to be updated to add an optional output parameter that might provide some clients with additional error information by following the existing pattern against the rest of the internal SDK.
To do this, I planned to update the IDL file so that it looks like this:
HRESULT CreateSomething(
[in] BSTR base_uri,
[in] ISomethingDescription* something_description,
[out, defaultvalue(0)] ErrorCode* error_code,
[out, retval] BSTR* something_uri
);
ErrorCode - , IDL. , , , defaultvalue retval. , ++, , , ..
HRESULT __stdcall CreateSomething(
BSTR study_uri,
ISomethingDescription* something_description,
ErrorCode* error_code = 0, // this is clearly wrong
BSTR* something_uri
);
, MSDN, , , defaultvalue retval , IDL, , , ++.
( ) MIDL, , ++, MIDL , .. :
virtual HRESULT STDMETHODCALLTYPE CreateSomething(
BSTR base_uri,
ISomethingDescription *something_description,
ErrorCode *error_code,
BSTR *something_uri) = 0;
SDK IDL ++ - , .
/ .