一个dll出错的问题

binscut 2002-12-04 04:33:07
在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)
...全文
51 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

15,471

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 进程/线程/DLL
社区管理员
  • 进程/线程/DLL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧