艾达,看看我的包裹。 (“预期的编译单元”?)
我已经摆脱了所有其他编译时错误,除了“预期编译单元”,它在我的导入语句之后开始。我猜我需要创建一个包?如果是这样,我该怎么做?我有几个函数都位于同一个 .ADB 文件中。
编辑:所以我试了一下...
查看我的包:
-- Import Statements
with Ada.Text_Io;
use Ada.Text_Io;
package body MyPackage is
-- Declarations
-- Functions
end MyPackage;
但是 gcc 在看到 MyPackage 时尖叫:
a_.adb:27:18: loop or block statement must follow label
a_.adb:27:18: reserved word "array" cannot be used as identifier
a_.adb:28:01: declarations must come before "begin"
Maximus graCimuS
I've gotten rid of all my other compile-time errors except "compilation unit expected", which starts right after my import statements. I'm guessing I need to create a package? And if so, how do I do it? I have a few functions all living in the same .ADB file.
EDIT: So I gave it a shot...
Check out my package:
-- Import Statements
with Ada.Text_Io;
use Ada.Text_Io;
package body MyPackage is
-- Declarations
-- Functions
end MyPackage;
But gcc screams when it sees MyPackage:
a_.adb:27:18: loop or block statement must follow label
a_.adb:27:18: reserved word "array" cannot be used as identifier
a_.adb:28:01: declarations must come before "begin"
Maximus graCimuS
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
包体是包规范的实现。
无意冒犯,但您需要熟悉一些基本的 Ada 编程概念。
也许可以从 Lovelace 教程开始,它是一个老东西,但却是一个好东西。
A package body is the implementation of a package specification.
No offense, but you need to familiarize yourself with some basic Ada programming concepts.
Maybe start with Lovelace Tutorial, it's an oldie but a goodie.
这些编译器消息不能属于您发布的代码(因为它没有 28 行)。
无论如何,GCC 都会期望此代码位于文件
mypackage.adb
中;并要求mypackage.ads
中有一个软件包规范。Those compiler messages can't belong to the code you posted (because it doesn't have 28 lines).
In any case, GCC will expect this code to be in a file
mypackage.adb
; and will require there to be a package spec inmypackage.ads
.有同样的错误,我忘记了它是如何工作的,所以经过一些尝试和错误后,我发现
而不是产生这个错误......
顺便说一句,它与包无关。
Had same error I forgot how it works so after some trial and error I found
instead of this that produce this error...
Btw it's not about packages.