gpt4 book ai didi

delphi - 编译此函数时没有响应?

转载 作者:行者123 更新时间:2023-12-03 14:58:04 27 4
gpt4 key购买 nike

我尝试使用 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;

最佳答案

它可以在我的电脑上编译。虽然我收到警告 W1036 变量“IsAllowed”可能尚未初始化。

更新:当我在使用子句中包含 Windows 时,我可以重现挂起。已提交至质量中心: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.

它看起来像一个错误;您应该在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;

关于delphi - 编译此函数时没有响应?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5975826/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com