一个dll出错的问题
在vc中test.c 有一个简单的求余数的函数
extern "C" __declspec(dllexport)
int __stdcall testfun(int a, int b)
{
int c;
c = a % b;
return c;
}
在vb中调用:
Private Declare Function testfun Lib "test" Alias "_testfun@8" (ByVal a As Integer, ByVal b As Integer) As Integer
Private Sub Command1_Click()
Dim a As Integer
Dim b As Integer
Dim c As Integer
a = Val(Text1.Text)
b = Val(Text2.Text)
c = testfun(a, b)
Label1.Caption = Str(a) & " % " & Str(b) & " = " & Str(c)
End Sub
结果是我在两个文本框中输入2个数22和33
输出错误结果为:22 % 33 =-11
然后我生成project1.exe并运行
得到的结果又是:22 % 33 = 22
不要以为这回答案是正确的,我再输入另外2个数:123和23
又输出错误结果:123 % 33 = 90
再试了几组数据
32 % 33 = 32
34 % 33 = 1
65 % 33 = 32
66 % 33 = 33
67 % 33 = 34
请问问题出在哪里呢?
补充一下,在VC编译时出了个link错误:
Compiling...
test.cpp
Linking...
LINK : LNK4073: cannot create map for .ILK file; linking nonincrementally
Creating library Debug/test.lib and object Debug/test.exp
test.dll - 0 error(s), 0 warning(s)