Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do we wrap C++ variable argument parameter in WinRT components

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?

like image 851
Prafulla Avatar asked Mar 09 '26 02:03

Prafulla


1 Answers

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.

like image 61
Stewart Avatar answered Mar 11 '26 07:03

Stewart



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!