在包装大dll之前,我正在测试JNA。基本功能与不同类型的args工作。但是,当我们在其中包装(甚至简单)包含标准方法mbstowcs的已批准代码时,就会出现如下情况:
Exception in thread "main" java.lang.Error: Invalid memory access
at com.sun.jna.Native.invokePointer(Native Method)
at com.sun.jna.Function.invokePointer(Function.java:490)
at com.sun.jna.Function.invokeString(Function.java:654)
at com.sun.jna.Function.invoke(Function.java:427)
at com.sun.jna.Function.invoke(Function.java:354)
at com.sun.jna.Library$Handler.invoke(Library.java:244)
at com.sun.proxy.$Proxy0.TestWCHAR_in(Unknown Source)
at gov.nbu.App.main(App.java:85)所有版本32位。
发布于 2017-09-19 07:40:05
问题不在南航。它出现在Cpp方面的一些机器(我的情况)。下面是:
void TestVoid(void)
{
wchar_t wcBuffer[2600] = {};
size_t szOut = 0;
std::string Path = "This message for test WCHAR.";
errno_t errCode = 0;
// Work:
errCode = mbstowcs_s(&szOut, wcBuffer, sizeof(wcBuffer), (char*)Path.c_str(), Path.size());
// Not work:
errCode = mbstowcs_s(&szOut, wcBuffer, Path.size(), (char*)Path.c_str(), Path.size());
}https://stackoverflow.com/questions/46176466
复制相似问题