GNAT.Sockets.Selector_Type 的地址子句是什么
What address clause for a GNAT.Sockets.Selector_Type
我在我的代码中使用 Selector_Type
。
一方面,Selector_Type
来自 GNAT.Sockets
comes with pragma:
pragma Volatile (Selector_Type);
另一方面,将 Gnatckeck 的 rule 9.1.1.2 应用到我的代码中会提高
volatile object with no address clause [Volatile_Objects_Without_Address_Clauses]
因为编译指示。
这个主题没有在 wikibook's example 中处理,我也没有在我的基本代码中的任何地方解决这个问题。
那么,我应该为我的选择器使用什么地址?
你不能。 Selector_Type
是可变的,因为它是操作系统的接口,并且可能(将)更改而无需 Ada 代码部分的任何操作。
我的试用示例是
package Rules is
type Selector is limited private;
private
type Selector is null record with Volatile;
S : Selector;
end Rules;
检查为
$ gnatcheck --show-rule rules.ads -rules +RVolatile_Objects_Without_Address_Clauses
rules.ads:5:04: volatile object with no address clause [Volatile_Objects_Without_Address_Clauses]
看来要查什么规则还得说,干嘛不select这个?
或者,如果您可以控制源,则可以应用 exemption。
在这种情况下,这看起来像
package Rules is
type Selector is limited private;
private
type Selector is null record with Volatile;
pragma Annotate (Gnatcheck, Exempt_On,
"Volatile_Objects_Without_Address_Clauses",
"only a demo!");
S : Selector;
pragma Annotate (Gnatcheck, Exempt_Off,
"Volatile_Objects_Without_Address_Clauses");
T : Selector;
end Rules;
现在检查为
$ gnatcheck --show-rule rules.ads -rules +RVolatile_Objects_Without_Address_Clauses
rules.ads:11:04: volatile object with no address clause [Volatile_Objects_Without_Address_Clauses]
(第11行为T
的未豁免申报;第8行S
的申报无投诉)
注:
对于这个答案的早期版本有一个根本性的误解,我们深表歉意。 gnatcheck 很好地支持该规则,只要您正确阅读它:它是关于没有地址子句的 volatile objects,而不是 volatile types.
我在我的代码中使用 Selector_Type
。
一方面,Selector_Type
来自 GNAT.Sockets
comes with pragma:
pragma Volatile (Selector_Type);
另一方面,将 Gnatckeck 的 rule 9.1.1.2 应用到我的代码中会提高
volatile object with no address clause [Volatile_Objects_Without_Address_Clauses]
因为编译指示。
这个主题没有在 wikibook's example 中处理,我也没有在我的基本代码中的任何地方解决这个问题。
那么,我应该为我的选择器使用什么地址?
你不能。 Selector_Type
是可变的,因为它是操作系统的接口,并且可能(将)更改而无需 Ada 代码部分的任何操作。
我的试用示例是
package Rules is
type Selector is limited private;
private
type Selector is null record with Volatile;
S : Selector;
end Rules;
检查为
$ gnatcheck --show-rule rules.ads -rules +RVolatile_Objects_Without_Address_Clauses
rules.ads:5:04: volatile object with no address clause [Volatile_Objects_Without_Address_Clauses]
看来要查什么规则还得说,干嘛不select这个?
或者,如果您可以控制源,则可以应用 exemption。
在这种情况下,这看起来像
package Rules is
type Selector is limited private;
private
type Selector is null record with Volatile;
pragma Annotate (Gnatcheck, Exempt_On,
"Volatile_Objects_Without_Address_Clauses",
"only a demo!");
S : Selector;
pragma Annotate (Gnatcheck, Exempt_Off,
"Volatile_Objects_Without_Address_Clauses");
T : Selector;
end Rules;
现在检查为
$ gnatcheck --show-rule rules.ads -rules +RVolatile_Objects_Without_Address_Clauses
rules.ads:11:04: volatile object with no address clause [Volatile_Objects_Without_Address_Clauses]
(第11行为T
的未豁免申报;第8行S
的申报无投诉)
注:
对于这个答案的早期版本有一个根本性的误解,我们深表歉意。 gnatcheck 很好地支持该规则,只要您正确阅读它:它是关于没有地址子句的 volatile objects,而不是 volatile types.