delphi - E2010 不兼容的类型
问题描述
我有两个单位:
unit D8;
interface
uses Darbas;
const
Ilgis = 100;
type
Tmas = array[1..Ilgis] of integer;
和
unit Darbas;
interface
const
Ilgis = 100;
type
Tmas = array[1..Ilgis] of integer;
procedure Ieskoti(X:Tmas; m:byte; var nr:byte);
我确实调用procedure Ieskoti
了unit D8
按钮单击事件:
procedure TfrmD8.btn4Click(Sender: TObject);
var
nr : Byte;
begin
Ieskoti(A, n, nr); //HERE I GET ERROR
end;
我确实得到了错误:
[dcc32 错误] D8.pas(130):E2010 不兼容的类型:“Darbas.Tmas”和“D8.Tmas”
解决方案
是的,这就是 Delphi 的类型系统的工作原理。
如果您在两个不同的位置定义了两个(静态或动态)数组类型,即使它们“相同” ,它们也不会是赋值兼容的。
你需要定义你的类型
type
Tmas = array[1..Ilgis] of Integer;
一次,然后在每次需要时引用此类型。
例如,您可以选择在Darbas
. 然后从你已经做的使用子句中删除类型定义D8
并包含Darbas
在其中。D8
uses
unit Darbas;
interface
const
Ilgis = 100;
type
Tmas = array[1..Ilgis] of Integer;
procedure Ieskoti(X: Tmas; m: Byte; var nr: Byte);
和
unit D8;
interface
uses Darbas;
interface
部分中的所有Darbas
内容现在都将在 中可见D8
,包括Ilgis
常量和Tmas
类型。
推荐阅读
- android - 旋转 YUV420 android.media.Image Android
- angular - 没有获得多个复选框的复选框真值和假值,角度
- flutter - 如何显示列表中的图像
- database - 我无法删除多个表中的所有记录
- javascript - 如何将原始 postgres 查询转换为根据创建的日期列选择当前年份以对查询进行后续处理?
- ios - Xamarin IOS 构建失败 <
> - php - ExtJS sprite 到 PDF,转换单位
- ubuntu - 如果我的配置需要密码,如何将 openvpn 客户端作为守护进程运行
- angular - 角度管理界面
- javascript - 如何使用 window.location.hash 和 reactjs 获取 url 值?