错误:声明必须在开始之前出现(Ada)

问题描述 投票:0回答:1
procedure Main is



begin



--  Insert code here.procedure LinkSort ;




  type JobType is (Accountant, Analysist, Manager, Manufacturing, Programmer,
             Inventory, Sales, SoftwareEnginner);
package JobTypeIO is new Ada.Text_IO.Enumeration_IO(JobType); use JobTypeIO;



type EmpName is (Ben, Betty, Bob, Damon, Darlene, David, Desire, Donald, Dustin,Jerry, Kevin, Mary, Marty, Sable, Sam, Sara, Teddy, Tom);package EmpNameIO is new Ada.Text_IO.Enumeration_IO(EmpName); use EmpNameIO;




type LegalResponce is (yup, y, yes, affirmative, nope, no, n, negative);subtype PositiveResponce is LegalResponce range yup..affirmative;package LegalIO is new Ada.Text_IO.Enumeration_IO(LegalResponce); use LegalIO;



package IntIO is new Ada.Text_IO.Integer_IO(Integer); use IntIO;null;end Main;



我尝试在开始之前插入声明,但弹出更多错误。这应该使用 IO 重定向,但我不知道我错过了什么。

ada io-redirection
1个回答
0
投票

我用

gnatpp
重新格式化了它,它给出了各种错误报告,直到我将
begin
after 声明(就像你在帖子标题中所说的那样),例如

begin
   null;
end Main;

之后的错误消息是

amb007.adb:7:29: error: "Ada" is undefined (more references follow)
amb007.adb:7:29: error: missing "with Ada.Text_IO.Enumeration_IO;"

解决这个问题,然后得到

amb007.adb:1:17: error: "Enumeration_IO" is a nested package, not a compilation unit

所以它需要只是

with Ada.Text_IO;
;就这样。

对于编程,你需要把东西记在脑子里;如果代码整洁,就会变得容易容易。

© www.soinside.com 2019 - 2024. All rights reserved.