DELPHI盒子
!实时搜索: 盒子论坛 | 注册用户 | 修改信息 | 退出
检举帖 | 全文检索 | 关闭广告 | 捐赠
技术论坛
 用户名
 密  码
自动登陆(30天有效)
忘了密码
≡技术区≡
DELPHI技术
lazarus/fpc/Free Pascal
移动应用开发
Web应用开发
数据库专区
报表专区
网络通讯
开源项目
论坛精华贴
≡发布区≡
发布代码
发布控件
文档资料
经典工具
≡事务区≡
网站意见
盒子之家
招聘应聘
信息交换
论坛信息
最新加入: senqicai
今日帖子: 2
在线用户: 15
导航: 论坛 -> DELPHI技术 斑竹:liumazi,sephil  
作者:
男 zwjchinazwj (蒲石) ★☆☆☆☆ -
普通会员
2018/10/12 12:29:17
标题:
编译器的问题,程序员的错。 浏览:1045
加入我的收藏
楼主: 尝试下面一段代码:

unit Unit1;
interface
uses
 VCL.Graphics;

procedure Test(Bmp: TBitmap);

implementation

uses
 Winapi.Windows;

procedure Test(Bmp: TBitmap);
begin

end;

end.

编译器报错:
[dcc32 Error]Unit1.pas(15): E2267 Previous declaration of 'Test' was not marked with the 'overload' directive

报告了Bug
https://quality.embarcadero.com/browse/RSP-21364?filter=-2

结果是:
Status: Resolved Resolved  
Resolution: Test Case Error
----------------------------------------------
-
作者:
男 kaida (kaida) ★☆☆☆☆ -
盒子活跃会员
2018/10/12 13:23:05
1楼: 确实是编译器问题,稍改一下就正常了:

unit Unit1;

interface

uses
 VCL.Graphics,  Winapi.Windows;

procedure Test(Bmp: TBitmap);

implementation

procedure Test(Bmp: TBitmap);
begin

end;

end.

这个问题由来已久,我用 Delphi 2006 编译也是同样错误。
----------------------------------------------
http://down.desei.com.cn/down/1041485/MyWeb/VCLs.html
作者:
男 bamlan (一丝清风) ★☆☆☆☆ -
盒子活跃会员
2018/10/12 14:31:19
2楼: 应该是你的Test函数参数中bmp的类型TBitmap没明确指定是哪个单元定义的,所以楼主的代码在Inteface节的定义引用的是vcl.Graphics的TBitmap,而在implementation节,实现引用了winapi.windows单元定义的TBitmap,把声明和实现都改成:
procedure Test(Bmp: Vcl.Graphics.TBitmap);
或者
procedure Test(Bmp: winapi.windows.TBitmap);
----------------------------------------------
-
作者:
男 wang_80919 (Flying Wang) ★☆☆☆☆ -
普通会员
2018/10/12 15:00:39
3楼: 楼上正解。
----------------------------------------------
(C)(P)Flying Wang
作者:
男 wang_80919 (Flying Wang) ★☆☆☆☆ -
普通会员
2018/10/12 15:03:18
4楼:
Alexey Kazantsev added a comment - 06/Oct/18 7:26 PM
This can broke other code. You can declare type alias for solve issues like this.
...
implementation
uses
 Winapi.Windows;
type
 TBitmap = VCL.Graphics.TBitmap;
----------------------------------------------
(C)(P)Flying Wang
作者:
男 zwjchinazwj (蒲石) ★☆☆☆☆ -
普通会员
2018/10/12 15:26:23
5楼: 呵呵。
----------------------------------------------
-
作者:
男 bahamut8348 (leonna) ★☆☆☆☆ -
普通会员
2018/10/12 20:27:28
6楼: 这个我觉得不是bug,只不过编译器吧同名的类型按最近定义去匹配罢了。
----------------------------------------------
--
信息
登陆以后才能回复
Copyright © 2CCC.Com 盒子论坛 v3.0.1 版权所有 页面执行66.40625毫秒 RSS