I have an exposed method that accepts a long* as a parameter like this:
void MyClass::MyPublicMethod(long *pLong)
Inside this method, I call a system API that accepts an INT64*, like this:
void MyClass::MyPublicMethod(long *pLong)
{
//SomeAPI::APIMethod(INT64* p64);
SomeAPI::APIMethod(&pLong);
}
When compiling as x64, I get an error (rightly so):
error C2664: 'SomeAPI::APIMethod(int64* p64)': cannot convert argument 1 from 'long*' to 'INT64*'
I do not want to change my exposed method's signature because it will have many downstream consequences. What is the best way to address this situation, assuming that I know that p64 will not exceed the limits of a long?
Something like this?
void MyClass::MyPublicMethod(long *pLong)
{
// Use a local INT64 for the API call.
INT64 tmp64 = *pLong;
//SomeAPI::APIMethod(INT64* p64);
SomeAPI::APIMethod(&tmp64);
*pLong = (long)tmp64;
}