سؤال

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