抑制 Ada 限制

Suppressing Ada Restriction

是否可以在源代码的特定部分抑制 ada 限制?例如,如果我在高级别定义了 "pragma Restrictions(No_Dynamic_Priorities)" 的使用,但希望在我知道我正在做的事情是安全的地方忽略此限制,是否可以抑制此限制,以便编译器不再抱怨?

你不能明确地否定一个限制;唯一的方法是只将限制应用于需要它的程序单元(即,不是 "at a high level")。

ARM 13.12, and (8.1) 中讨论了限制

A restriction may impose requirements on some or all of the units comprising the partition. Unless otherwise specified for a particular restriction, such a requirement applies to all of the units comprising the partition and is enforced via a post-compilation check.

在您的特定情况下,ARM D.7(9) 表示 No_Dynamic_Priorities

There are no semantic dependences on the package Dynamic_Priorities, and no occurrences of the attribute Priority.

这不会覆盖一般要求;所以我认为你想做的事情是不允许的。