My Java code is using native method (win API) for opening a file where that native method is implemented in C++. I dont have any idea about win API. When I try to compile that C++ project, I am getting the above mentioned error.
The code responsible for error as follows:
std::wstring getUnicodeString(JNIEnv *env, jstring str)
{
jboolean isCopy;
jsize len = env->GetStringLength(str);
LPTSTR unicodeString = (LPTSTR) malloc (2 * len + 2);
memset (unicodeString, 0, 2 * len + 2);
LPCWSTR tempStr = env->GetStringChars(str, &isCopy); // <--- this line
memcpy(unicodeString, tempStr, 2 * len );
std::wstring result = unicodeString;
env->ReleaseStringChars(str, tempStr);
delete unicodeString;
return result;
}
I am getting error in the highlighted line. Initially I thought this must be a conversion error so I did typecasting. After typecasting, the error in that particular line got resolved but I got so many errors based on the dependency.
I think there is no problem with the code because this code got compiled several times previously. I think this might be some unicode settings issue in Visual Studio. Please help