C++;从Windows CE上的C#为ARM调用的DLL始终返回0
我目前正在TI OMAP处理器上为Windows CE开发一个应用程序,这是一个ARM处理器。我试图简单地调用C++中的C++ DLL文件中的函数,并且不管使用哪种数据类型,我总是得到0的值。这很可能是某种调用约定不匹配吗?我正在从同一个VisualStudio解决方案编译DLL和主EXE C#代码片段:C++;从Windows CE上的C#为ARM调用的DLL始终返回0,c#,c++,interop,windows-ce,arm,C#,C++,Interop,Windows Ce,Arm,我目前正在TI OMAP处理器上为Windows CE开发一个应用程序,这是一个ARM处理器。我试图简单地调用C++中的C++ DLL文件中的函数,并且不管使用哪种数据类型,我总是得到0的值。这很可能是某种调用约定不匹配吗?我正在从同一个VisualStudio解决方案编译DLL和主EXE C#代码片段: public partial class Form1 : Form { private void button1_Click(object sender, EventArgs e)
public partial class Form1 : Form
{
private void button1_Click(object sender, EventArgs e)
{
byte test = LibWrap.test_return();
MessageBox.Show(test.ToString());
}
}
public class LibWrap
{
[DllImport("Test_CE.dll")]
public static extern byte test_return();
}
extern "C" __declspec (dllexport) unsigned char test_return() {
return 95;
}
C++DLL代码段:
public partial class Form1 : Form
{
private void button1_Click(object sender, EventArgs e)
{
byte test = LibWrap.test_return();
MessageBox.Show(test.ToString());
}
}
public class LibWrap
{
[DllImport("Test_CE.dll")]
public static extern byte test_return();
}
extern "C" __declspec (dllexport) unsigned char test_return() {
return 95;
}
当我改变时,它起作用了:
extern "C" __declspec (dllexport) unsigned char test_return() {
return 95;
}
到
在DLL代码中。我无法理解为什么在为WinCE编译时它不假定这一点。请尝试导出测试返回(),如下所示:
unsigned char __declspec(dllexport) WINAPI test_return() {
return 95;
}
WINAPI被定义为 __stdcall在它应该在的地方uu cdecl
没有。WINAPI被定义为u stdcall。刚刚在Windows Mobile 2005 R2 Emulator上测试过,工作非常完美。WINAPI在某个地方被定义为u stdcall,而它本应该是u cdeclBen:可能是项目设置问题。默认的VS2008 Windows Mobile项目设置对我来说很好。这应该是Ben评论下面的评论,而不是新的答案。