I have what I hope is a basic question, but I've been unsuccessful finding any documentation or examples on MSDN or the internet in general.
I'm implementing a windows runtime component in C++/WinRT. I have an asynchronous method that scans for the presence of a specific type of device and returns a vector of strings (device IDs) of devices found. The C++ signature of the function is:
static IAsyncOperation<IVector<winrt::hstring>> ScanInterfacesAsync();
I have been unsuccessful in getting an authoring an IDL that projects this function to the runtime. My best guess:
static IAsyncOperation<IVector<String>> ScanInterfacesAsync();
Fails with an error:
error MIDL2025: [msg]syntax error [context]: expecting > or , near ">>"
I've tried a few other things but I can tell I just fundamentally don't understand how IDL works with templates. And I can't find any examples of a templated return type in any of the online IDL documentation.
Is this possible? What's the right syntax? Any pointers to documentation I've overlooked? Thanks.
The error message seems to indicate, that MIDL 3.0 uses a greedy parser. It interprets the two consecutive closing angle brackets (>
) as a single right-shift operator (>>
), much like C++ did prior to C++11 (see right angle bracket).
To work around this, MIDL 3.0 source needs to introduce arbitrary whitespace (e.g. a single space character) in between consecutive closing angle brackets so that it gets interpreted as two distinct tokens as opposed to a single token. The following should compile:
static IAsyncOperation<IVector<String> > ScanInterfacesAsync();