鱼C论坛

 找回密码
 立即注册
查看: 1751|回复: 4

[已解决]新手求助dll文件按照小甲鱼老师的教的写的,还是报错,请大神给看看

[复制链接]
发表于 2019-5-17 20:23:22 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
library Project2;

{ Important note about DLL memory management: ShareMem must be the
  first unit in your library's USES clause AND your project's (select
  Project-View Source) USES clause if your DLL exports any procedures or
  functions that pass strings as parameters or function results. This
  applies to all strings passed to and from your DLL--even those that
  are nested in records and classes. ShareMem is the interface unit to
  the BORLNDMM.DLL shared memory manager, which must be deployed along
  with your DLL. To avoid using BORLNDMM.DLL, pass string information
  using PChar or ShortString parameters. }

uses
  SysUtils,
  Classes;

{$R *.res}

Function max(x,y,z:integer):integer;StdCall;
var
t: integer;
begin
if(x<y) then
t:=y
else
t:=x;

if(t<z) then
t:=z
else
max:=t;
end;

Function min(x,y,z:integer):integer;StdCall;
var
t: integer;
begin
if(x>y) then
t:=y
else
t:=x;
if(t>z) then
t:=z
else
min:=t;
end;
exports
max,min;
begin
end.
最佳答案
2019-5-17 21:53:50
2个提示而已。不过话说,这是你自己写的代码吧。不要把责任推给小甲鱼老师。
一个函数要在任何时候都有返回值。比如说你这个
  1. Function max(x,y,z:integer):integer;StdCall;
  2. var
  3. t: integer;
  4. begin
  5.   if x<y  then
  6.     t:=y
  7.   else
  8.     t:=x;

  9.   if t<z  then
  10.     t:=z;

  11.   max:=t;
  12. end;
复制代码


对比下,你的函数保证能在任何情况下都有返回值吗?
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

 楼主| 发表于 2019-5-17 20:28:08 | 显示全部楼层
老提示value assigned to 't' never used   return value of function 'max'  might be undefined;
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2019-5-17 21:53:50 | 显示全部楼层    本楼为最佳答案   
2个提示而已。不过话说,这是你自己写的代码吧。不要把责任推给小甲鱼老师。
一个函数要在任何时候都有返回值。比如说你这个
  1. Function max(x,y,z:integer):integer;StdCall;
  2. var
  3. t: integer;
  4. begin
  5.   if x<y  then
  6.     t:=y
  7.   else
  8.     t:=x;

  9.   if t<z  then
  10.     t:=z;

  11.   max:=t;
  12. end;
复制代码


对比下,你的函数保证能在任何情况下都有返回值吗?
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2019-8-7 14:24:35 | 显示全部楼层
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2019-8-17 18:27:04 | 显示全部楼层
你好,楼主,问题解决了,请结帖!
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-4-20 11:45

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表