规范文件 (.ads) 中的不可见声明

Non-visible declaration in specification file (.ads)

我不断收到下面所述的错误。我已将有问题的记录移入和移出包的私有部分,但错误仍然存​​在。我是 Ada 的新手,我在实现这个通用堆栈以保存记录数组时遇到问题。

我已将记录和类型声明移入和移出私有部分。我还尝试在代码中看到的私有部分之前添加 "type garagebay is private" 声明。

-- .ads file --
generic
  low: integer; --lowerbound of stack
  up: integer; -- upperbound of stack
  type item is private; -- type of stack

package gstack is
  type garageBay is private;

  procedure tpush(x: in item);
  procedure tpop(x: out item);
private
  type vehicle is array(1..15) of character;
  type vName is array(1..8) of character;
  type garageBay is record
      vehicleType: vehicle;
      vehicleName: vName;
      time2Fix: integer;
      startTime: integer;
      finishTime: integer;
  end record;
  type entries is array(low..up) of item;
end gstack;
-- driver file
with Ada.Text_IO; use Ada.Text_IO;  -- in file Gusestac.adb
with gstack;  -- generic stack defined in gstack10.ads /.adb
procedure gusestack is
    package IIO is new Ada.Text_IO.Integer_IO(integer); use IIO;
    lowerbound: integer;
    upperbound: integer;
begin
    get(lowerbound);
    get(upperbound);
    declare
      package genericS is new gstack(lowerbound,upperbound, garageBay);
      use genericS;
    begin
      put(""); -- placeholder
    end;
end gusestack;
-- Errors
x86_64-linux-gnu-gcc-8 -c gusestack.adb
gusestack.adb:11:63: "garageBay" is not visible
gusestack.adb:11:63: non-visible declaration at gstack.ads:7
gusestack.adb:11:63: instantiation abandoned
gusestack.adb:12:13: "genericS" is undefined
gnatmake: "gusestack.adb" compilation Error

您正在尝试使用通用包 gstack 中定义的类型 garageBay 来创建 gstack 的具体实例。在实例化 gstack.

之前,您可能希望将类型定义 garageBaygstack 的私有部分移动到 gusestack 的声明部分