包不可见错误

Dr.*_*son 3 ada gnat

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

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
Run Code Online (Sandbox Code Playgroud)

包装规格如下:

package Viterbi is

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

end Viterbi;
Run Code Online (Sandbox Code Playgroud)

包体如下:

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;
Run Code Online (Sandbox Code Playgroud)

我的包裹体中是什么导致包裹保持隐藏状态?use 子句不应该将 Integer_Text_IO 带入视野吗?

Mar*_*c C 5

提供的包体代码有语法错误:“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
   ...
Run Code Online (Sandbox Code Playgroud)

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