Package not visible error

9.1k views Asked by At

I've having trouble with package visibility. I have a really simple package and the code is listed below. The error message is shown here:

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

The package specification is as follows:

package Viterbi is

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

end Viterbi;

The package body is as follows:

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;

What in my package body is causing the package to stay hidden? Shouldn't the use clause bring Integer_Text_IO into view?

2

There are 2 answers

1
Marc C On BEST ANSWER

The code of the package body as provided has a syntax error: the spurious "with" in the "use with Ada.Integer_Text_IO;" clause.

Having fixed that, I then get compilation errors revolving around the inability to resolve File_Type, Open, and Close. Adding a "with" and "use" of Ada.Text_IO gives me a clean compilation.

So the start of the package body looks like:

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
   ...

If you're still getting a "can't find Integer_Text_IO" error after fixing these errors, then I'd be suspicious about your development environment, i.e. is everything installed correctly?

1
Shark8 On

You can avoid the "use with" style of error, as already pointed out, by using the comma-separated style: With -- Testing, Ada.Integer_Text_IO, Ada.Strings;

Use
-- Testing,
Ada.Strings,
Ada.Integer_Text_IO;

this also allows you to comment out specific package 'withs' or 'usues' as shown.