use*_*ser 6 delphi compilation delphi-xe
我尝试使用Delphi XE编译时没有响应.它是否适用于您的计算机或功能有问题?
function Test(const FileName: string;
const Force: boolean = false): boolean;
var
IsAllowed: boolean;
begin
result := false;
if FileExists(FileName) then
begin
try
if (Force) then
begin
result := false;
exit;
end;
finally
if IsAllowed then
DeleteFile(FileName);
end;
try
result := true;
except
result := false;
end;
end;
end;
Run Code Online (Sandbox Code Playgroud)
Ond*_*lle 11
它编译在我的电脑上.虽然我收到警告W1036变量'IsAllowed'可能尚未初始化.
更新:当我在uses子句中包含Windows时,我可以重现挂起. 提交给Quality Central:QC93806.
program hang_test;
{$APPTYPE CONSOLE}
uses
// Windows, // uncomment to include Windows -> hang on compile
SysUtils;
function Test(const FileName: string; const Force: boolean = false): boolean;
// your function here
begin
try
except
on E: Exception do
Writeln(E.ClassName, ': ', E.Message);
end;
end.
Run Code Online (Sandbox Code Playgroud)
它看起来像一个bug; 您应该在Quality Central中报告它.
更新2:可重复挂起编译器的最小情况:
function HangCompiler: Boolean;
begin
try
Exit; // 1. exit from a try..finally
finally
DeleteFile(''); // 2. inlined function call in finally (include Windows to inline)
end;
// 3. try..except
try
Result := True;
except
Result := False;
end;
end;
Run Code Online (Sandbox Code Playgroud)