★下面这些[warning]信息什么意思?除了第一条外我都有相应的语句声名(50分)

  • 主题发起人 volcanosh
  • 开始时间
V

volcanosh

Unregistered / Unconfirmed
GUEST, unregistred user!
★下面这些[warning]信息什么意思?除了第一条外我都有相应的语句声名

[Warning] ghostMain.pas(7): Unit 'FileCtrl' is specific to a platform

[Warning] ghostMain.pas(63): Return value of function 'charOrder' might be undefined
对应的function charOrder(achar:char):integer;

[Warning] ghostMain.pas(98): Variable 'DriveSize' might not have been initialized
[Warning] ghostMain.pas(98): Variable 'DriveFree' might not have been initialized
对应的 DriveSize:int64;
DriveFree:int64;
 
[Warning] ghostMain.pas(63):
函数的返回值可能没有,你的Result语句可能在一条判断语句中,
如果是这样,在编译器不能判断的情况下将会提示你没有定义。
[Warning] ghostMain.pas(98):
虽然给出了定义,但是没有被初始化。一旦使用,它的值将是不确定的。
 
第一个,FileCtl只适用于Windows平台,Linux下的Kylix无法直接使用包含Filectl的代码
第二个,函数的返回值有可能没有定义,比如
function charOrder(achar:char):integer;
begin
if achar='A' then Exit; //如果achar刚好为A,直接退出,函数返回值旧没有定义
result:=0;
....
end;
第三/四个,DriveSize这个变量可能没有初始化,比如
for drivesize:=0 to 10 do ...;
if drivesize<100 then ...//这时候就会告诉你,可能没有初始化。这种到无所谓
另外
procedure myExample;
var
i: integer;
begin
if i<10 then ...//这里也会告诉你没有初始化
end;
 
[Warning] ghostMain.pas(7): Unit 'FileCtrl' is specific to a platform
FileCtrl单元的函数依赖于某种确定的操作系统,在其他平台的操作系统上编译将会有问题。

其他的同 twos。
 
局部变量最好先自己进行初始化
全局变量就不用了
 
多人接受答案了。
 
顶部