我不断得到下面所述的错误。我已经将违规记录移入和移出包的私有部分,但错误仍然存在。我是Ada的新手,我在实现这个通用堆栈来保存记录数组时遇到了问题。
我已经将记录和类型声明移入和移出了private部分。我还尝试在私有部分之前添加"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发布于 2019-09-17 13:32:26
您正在尝试使用泛型包gstack中定义的garageBay类型来创建gstack的具体实例。在实例化gusestack之前,您可能希望将类型定义garageBay从gstack的私有部分移到gusestack的声明部分。
https://stackoverflow.com/questions/57964627
复制相似问题