Search code examples
c++arraysatl

C++ MIDL2025: Expecting a type specification near ""


I want my IDL file to implement a function that returns String array, so I tried it like:

[id(2)] HRESULT GReport_Person1([out, retval] std::vector<std::string> *Result);
[id(3)] HRESULT GReport_Person2([out, retval] std::vector<BSTR> *Result);

But this generates the error:

MIDL2025 syntax error : expecting a type specification near "std"

But I want it to return this array or a std::vector<BSTR> anyway, please help me to resolve this.


Solution

  • You can't use the std containers in MIDL and COM in such a way.

    Either you have to use pointers and arrays as memory block in COM. So you can use MIDL arrays. Here are some different types of arrays in MIDL syntax

    If you want to use the interface in automation you have to use VARIANT elements containing a SafeArray. Standard Automation with IDispatch (VBScript) only supports SafeArrays of VARIANTS again. But you are free to use SafeArrays of BSTR too.