I have a C++ method that takes variable argument as init param. Something like

MyMethod(std::wchar_t*, ...)

Can someone please let me know how can we write a WinRT component wrapper to expose the variable arguments?

有帮助吗?

解决方案

WinRT metadata does not support vararg functions, so there is no good way to do this. The answer therefore depends on what the function actually does. Assuming it is some kind of string formatting function I would suggest wrapping it with something like:-

MyMethod(Platform::String^, Windows::Foundation::Collections::IVector<Platform::Object^>^ params);

This will allow you to take the variable arguments.

The problem of course is that this has completely different semantics from what you have. The caller is going to have to pack up an array, and you won't be able to call your existing method easily with the arguments from the vector.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top