Re: VS2005 : Managed Wrapper for Unmanaged code : Ellipsis dilema
- From: adebaene@xxxxxxxxxxxxxxxx
- Date: Wed, 17 Oct 2007 05:31:18 -0700
On Oct 17, 9:43 am, "Olivier Matrot"
<olivier.matrot....@xxxxxxxxxxxxx> wrote:
Hello,
I'm in the process of writing a managed wrapper on legacy C++ code.
I have to deal with methods that are using the ellipsis.
For instance,the legacy method is :
void CLog::Print (LPCSTR szMask, ...)
{
CHAR szText[512];
va_list arglist;
va_start (arglist, szMask);
wvsprintfA (szText, szMask, arglist);
va_end (arglist);
}
The wrapper looks like this :
void Print(System::String ^ Text, array<Object^>^ args )
{
CStringA s((LPCTSTR)UnmanagedString(Text));
m_pLog->Print(s, args);
Here, you are passing an array<Object^>^ as the 1st ellipsis argument,
while the native part (eg, wvsprintf) expects an int. It not a
surprise it doesn't work..
I do not see any simple solution. IMHO, you should anyway get way of
those ugly, type-unsafe- c-styleish, ellipsis. You could for example
design your wrapper class to work like a stream or a StringBuilder.
Arnaud
.
- Follow-Ups:
- Re: VS2005 : Managed Wrapper for Unmanaged code : Ellipsis dilema
- From: Olivier Matrot
- Re: VS2005 : Managed Wrapper for Unmanaged code : Ellipsis dilema
- References:
- VS2005 : Managed Wrapper for Unmanaged code : Ellipsis dilema
- From: Olivier Matrot
- VS2005 : Managed Wrapper for Unmanaged code : Ellipsis dilema
- Prev by Date: Re: passing std::string from visual studio 2005 to an C++ DLL generated by VC 6.0
- Next by Date: Re: passing std::string from visual studio 2005 to an C++ DLL generated by VC 6.0
- Previous by thread: VS2005 : Managed Wrapper for Unmanaged code : Ellipsis dilema
- Next by thread: Re: VS2005 : Managed Wrapper for Unmanaged code : Ellipsis dilema
- Index(es):
Relevant Pages
|