A Riddle: Why does this line doesn't compile

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Line:
********
HRESULT CMngdServer::IServerSink::OnReceive(System::IntPtr pbtBuf)
{
void *pBtData = (void*)System::IntPtr::op_Explicit(pbtBuf);// <-- Produce the error
}

The output:
************
error C2668: 'System::IntPtr::op_Explicit' : ambiguous call to overloaded function
could be '__int64 System::IntPtr::op_Explicit(System::IntPtr)'
or 'int System::IntPtr::op_Explicit(System::IntPtr)'
or 'void *System::IntPtr::op_Explicit(System::IntPtr)'
while trying to match the argument list '(System::IntPtr)'

Why is that happening? Why does the compiler produce this kind of error?

Nadav
http://www.ddevel.com
 
Maybe you shouldn't call the operator explicitly instead you simply invoke
it by casting: (void*).
 
Back
Top