C ++ DLL called from C # in Windows CE for ARM Always returns 0

I am currently developing a Windows CE application on the TI OMAP processor, which is an ARM processor. I am trying to just call a function in a C ++ DLL file from C # and I always get the value 0 back, no matter what data type I use. Is this likely some kind of inconsistency of the convening agreement? I am compiling a DLL and a basic EXE from the same Visual Studio solution.

C # code snippet:

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();
}

C ++ DLL code snippet:

extern "C" __declspec (dllexport) unsigned char test_return() {
    return 95;
}
+3
source share
3 answers

This worked when I changed:

extern "C" __declspec (dllexport) unsigned char test_return() {
    return 95;
}

to

extern "C" __declspec (dllexport) unsigned char __cdecl test_return() {
    return 95;
}

In the dll code. Why doesn't he assume this when compiling for WinCE goes beyond me.

+2

test_return() :

unsigned char __declspec(dllexport) WINAPI test_return() {
   return 95;
}
0

- WINAPI __stdcall, __cdecl

No. WINAPI is defined as __stdcall.

0
source

Source: https://habr.com/ru/post/1711772/


All Articles