首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >规范文件(.ads)中的不可见声明

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

Stack Overflow用户
提问于 2019-09-17 05:28:02
回答 1查看 214关注 0票数 1

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

我已经将记录和类型声明移入和移出了private部分。我还尝试在私有部分之前添加"type garagebay is private“声明,如代码所示。

代码语言:javascript
复制
-- .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;
代码语言:javascript
复制
-- 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;
代码语言:javascript
复制
-- 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
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-09-17 13:32:26

您正在尝试使用泛型包gstack中定义的garageBay类型来创建gstack的具体实例。在实例化gusestack之前,您可能希望将类型定义garageBaygstack的私有部分移到gusestack的声明部分。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57964627

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档