在 Ada 中使用 Pragma
谁能给我提供一些简单的工作示例来说明 Ada 2005 中编译指示的使用?我知道编译指示用于优先级流程,只是我还没有遇到过工作示例!
非常感谢!
Can anyone supply me with simple working examples which illustrate the use of pragmas in Ada 2005 ? I understand that pragmas are used to priorities processes, just that I have not come across working examples !
Much appreciated !
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
Ada pragma 是一种语言功能,允许调整或微调 Ada 程序的行为。 Ada 语言标准定义了许多编译指示,但编译器供应商也可以定义自己的编译指示。
编译指示的主题涵盖的不仅仅是流程[任务]优先级,这里有一个列表需要检查的标准和供应商提供的编译指示。
您究竟想借助实用程序做什么?设定任务优先级?
An Ada pragma is a language feature that allows adjusting or fine-tuning the behavior of an Ada program. A number of pragmas are defined by the Ada language standard, but compiler vendors can also define their own.
The subject of pragmas cover far more than just process [tasking] priorities, here's a list of standard and vendor-provided pragmas to check out.
What exactly are you trying to do with the aid of pragmas? Set task priorities?
与 Ada 的大部分内容一样,我认为这里最好的答案实际上是咨询LRM。 管理任务优先级的部分实际上非常可读,无论如何,对于语言标准定义。
请注意,您还可以在运行时设置任务的优先级< /a> 不使用编译指示。这利用了
Ada.Dynamic_Priorities
包。这就是我现在通常做的事情,除非出于某种奇怪的原因在编译时就知道所需的优先级,并且我不介意对其进行硬编码。我强烈建议像您这样的高级用户浏览一下 LRM,看看所有语言都为您提供了什么。请特别注意附件(以字母开头的部分),因为这是记录大多数好东西的地方。就您而言,您可能会对实时附件(附件 D)特别感兴趣。
As with much of Ada, I think the best answer here is really to consult the LRM. The section on managing task priorities is actually very readable, for a language standard definition anyway.
Note that you can also set the priority of a task at runtime without use of a pragma. This makes use of the package
Ada.Dynamic_Priorities
. This is what I typically do these days, unless for some weird reason the desired priority is known at compile time, and I don't mind hard-coding it.I highly suggest that advanced users such as yourself poke through the LRM to see what all the language provides you. Pay particular attention to the annexes (the sections starting with a letter), as that is where most of the good stuff is documented. In your case, you will probably be particularly interested in the Real-Time annex (Annex D).
搜索
comp.lang.ada
有关优先级<的最新讨论/code>
有几个有趣的例子。 这个似乎特别适合您的问题。
附录:另外两个示例性来源是 Ada 95 的基本原理和 Ada 2005 的基本原理
A search of
comp.lang.ada
for recent discussions aboutpriorities
has several interesting examples. This one seems particularly apropos to your question.Addendum: Two other exemplary sources are the Rationale for Ada 95 and Rationale for Ada 2005
是的,我看到这个经常用来让编译器关闭过程中未引用的变量:
Yep, I see this one used often to shut the compiler up about unreferenced variables in a procedure: