Package not visible error

Dr. Watson picture Dr. Watson · Feb 4, 2011 · Viewed 7.6k times · Source

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?

Answer

Marc C picture Marc C · Feb 5, 2011

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?