下面是我做的一个DLL,build有问题:
[Error] dllcomserver.dpr(10): Undeclared identifier: 'Interger'
[Error] dllcomserver.dpr(23): Declaration of 'max' differs from previous declaration
[Warning] dllcomserver.dpr(25): Comparing signed and unsigned types - widened both operands
[Error] dllcomserver.dpr(31): Declaration of 'mix' differs from previous declaration
[Warning] dllcomserver.dpr(33): Comparing signed and unsigned types - widened both operands//文件中的代码
library dllcomserver;uses
SysUtils,
Classes;type
TComp=Class
public
function max(x,y:Interger):Integer;virtual;abstract;
function mix(x,y:Interger):Integer;virtual;abstract;
end;type
TCompImpl=Class(TComp)
public
function max(x,y:Interger):Integer;override;
function mix(x,y:Interger):Integer;override;
end;{TCompImpl}function TCompImpl.max(x,y:Integer):Integer;
begin
if x>y then
result:=x
else
result:=y;
end;function TCompImpl.mix(x,y:Integer):Integer;
begin
if x<y then
result:=x
else
result:=y;
end;function CreateCompImpl:TCompImpl;stdcall;
begin
result:=TCompImpl.Create;
end;function add(x,y:Interger):Interger;stdcall;
begin
result:=x+y;
end;function multi(x,y:Interger):Interger;stdcall;
begin
result:=x*y;
end;exports
add,multi,CreateCompImpl;
begin
end.
[Error] dllcomserver.dpr(10): Undeclared identifier: 'Interger'
[Error] dllcomserver.dpr(23): Declaration of 'max' differs from previous declaration
[Warning] dllcomserver.dpr(25): Comparing signed and unsigned types - widened both operands
[Error] dllcomserver.dpr(31): Declaration of 'mix' differs from previous declaration
[Warning] dllcomserver.dpr(33): Comparing signed and unsigned types - widened both operands//文件中的代码
library dllcomserver;uses
SysUtils,
Classes;type
TComp=Class
public
function max(x,y:Interger):Integer;virtual;abstract;
function mix(x,y:Interger):Integer;virtual;abstract;
end;type
TCompImpl=Class(TComp)
public
function max(x,y:Interger):Integer;override;
function mix(x,y:Interger):Integer;override;
end;{TCompImpl}function TCompImpl.max(x,y:Integer):Integer;
begin
if x>y then
result:=x
else
result:=y;
end;function TCompImpl.mix(x,y:Integer):Integer;
begin
if x<y then
result:=x
else
result:=y;
end;function CreateCompImpl:TCompImpl;stdcall;
begin
result:=TCompImpl.Create;
end;function add(x,y:Interger):Interger;stdcall;
begin
result:=x+y;
end;function multi(x,y:Interger):Interger;stdcall;
begin
result:=x*y;
end;exports
add,multi,CreateCompImpl;
begin
end.
interger ------> integer
这样编译就通过了。
不用在uses里加system,编译器会自动识别integer类型,如果加上的话,会造成dll文件很大,不信你试试。