{DCC 警告} W1036 变量“$frame”可能没有初始化?
为什么我在 Delphi XE 中收到此警告的任何想法:
[DCC 警告] Form1.pas(250): W1036 变量 '$frame' 可能尚未初始化
procedure TForm1.Action1Execute(Sender: TObject);
var
Thread: TThread;
begin
...
Thread := TThread.CreateAnonymousThread(
procedure{Anonymos}()
procedure ShowLoading(const Show: Boolean);
begin /// <------------- WARNING IS GIVEN FOR THIS LINE (line number 250)
Thread.Synchronize(Thread,
procedure{Anonymous}()
begin
...
Button1.Enabled := not Show;
...
end
);
end;
var
i: Integer;
begin
ShowLoading(true);
try
Thread.Synchronize(Thread,
procedure{Anonymous}()
begin
... // some UI updates
end
Thread.Synchronize(Thread,
procedure{Anonymous}()
begin
... // some UI updates
end
);
finally
ShowLoading(false);
end;
end
).NameThread('Some Thread Name');
Thread.Start;
end;
我的代码中没有任何地方有变量名称框架或 $frame。我什至不确定带有 $ 符号的 $frame 如何成为有效的标识符。
对我来说,这就像编译器的魔法。
PS:当然,现实生活中的 xosw 除了 Form1、Button1、Action1 之外还有其他名称。
Any ideas why I get this warning in Delphi XE:
[DCC Warning] Form1.pas(250): W1036 Variable '$frame' might not have been initialized
procedure TForm1.Action1Execute(Sender: TObject);
var
Thread: TThread;
begin
...
Thread := TThread.CreateAnonymousThread(
procedure{Anonymos}()
procedure ShowLoading(const Show: Boolean);
begin /// <------------- WARNING IS GIVEN FOR THIS LINE (line number 250)
Thread.Synchronize(Thread,
procedure{Anonymous}()
begin
...
Button1.Enabled := not Show;
...
end
);
end;
var
i: Integer;
begin
ShowLoading(true);
try
Thread.Synchronize(Thread,
procedure{Anonymous}()
begin
... // some UI updates
end
Thread.Synchronize(Thread,
procedure{Anonymous}()
begin
... // some UI updates
end
);
finally
ShowLoading(false);
end;
end
).NameThread('Some Thread Name');
Thread.Start;
end;
I do not have anywhere in my code a variable names frame nor $frame. I am even not sure how $frame with $ sign can be a valid identifier.
Smells like compiler magic to me.
PS: Of course the real life xosw is having other than Form1, Button1, Action1 names.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 XE2 中,不存在此编译器警告。
不管怎样,为了让你的方法对编译器来说更清晰一点,试试这个:
更新:
我刚刚检查了 XE,这确实修复了编译器警告。
我在问题评论中给出的参考解释了警告和框架对象。
所以我猜想 XE 编译器对 ShowLoading 正在创建的框架对象感到困惑。并创建显式引用修复了警告。
更新2:
仅展示我的测试供您参考:
In XE2 this compiler warning is not there.
Anyway, to make your method a bit clearer to the compiler, try this :
Update :
I just checked in XE, this really fixes the compiler warning.
The reference I gave in the comment to the question explains about the warning and frame objects.
So I guess that the XE compiler is getting confused about the frame object ShowLoading is creating. And creating an explicit reference fixed the warning.
Update 2 :
Just showing my test for your reference :