gpt4 book ai didi

ada - 包不可见错误

转载 作者:行者123 更新时间:2023-12-01 11:06:44 25 4
gpt4 key购买 nike

我在包裹可见性方面遇到了问题。我有一个非常简单的包,下面列出了代码。错误信息显示在这里:

viterbi.adb:12:14: "Integer_Text_IO" is not visible (more references follow)
viterbi.adb:12:14: non-visible declaration at a-inteio.ads:18
gnatmake: "viterbi.adb" compilation error

封装规范如下:

package Viterbi is

procedure Load_N_File(
Filename : in String;
N : in out Integer;
M : in out Integer);

end Viterbi;

包体如下:

with Ada.Integer_Text_IO; use with Ada.Integer_Text_IO;
with Ada.Strings; use Ada.Strings;

package body Viterbi is

procedure Load_N_File(
Filename : in String;
N : in out Integer;
M : in out Integer
) is
N_File : File_Type;
begin
Open( N_File, Mode=>In_File, Name=>Filename );
Get( N_File, N );
Get( N_File, M );
Close( N_File );
end Load_N_File;

end Viterbi;

我的包体中有什么导致包保持隐藏状态? use 子句不应该将 Integer_Text_IO 引入 View 吗?

最佳答案

所提供的包体代码存在语法错误:“use with Ada.Integer_Text_IO;”中的虚假“with”条款。

修复该问题后,我会遇到围绕无法解析 File_TypeOpenClose 的编译错误。添加 Ada.Text_IO 的“with”和“use”给我一个干净的编译。

所以包体的开头是这样的:

with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
with Ada.Strings; use Ada.Strings;
with Ada.Text_IO; use Ada.Text_IO;

package body Viterbi is
...

如果在修复这些错误后您仍然收到“找不到 Integer_Text_IO”错误,那么我会怀疑您的开发环境,即所有安装是否正确?

关于ada - 包不可见错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4903255/

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