gpt4 book ai didi

ada - 检测 GNAT 预定义库中的匿名分配

转载 作者:行者123 更新时间:2023-12-04 01:54:31 24 4
gpt4 key购买 nike

所以我正在开发一个 Ada 2012 库,它不应该从默认池中执行分配;所有这些都应该使用用户指定的存储池。

我正在使用一些预定义的包,其中一些显然不遵守规则:例如无限期容器。我想确定我没有使用我不应该使用的东西。

我认为一些 pragma Restrictions 会有所帮助,但以下都没有提示:

pragma Restrictions (No_Allocators);
pragma Restrictions (No_Anonymous_Allocators);
pragma Restrictions (No_Implicit_Heap_Allocations);
pragma Restrictions (No_Standard_Allocators_After_Elaboration);
pragma Restrictions (No_Standard_Storage_Pools);

with Ada.Containers.Indefinite_Vectors;

procedure Anon is
package Vectors is new Ada.Containers.Indefinite_Vectors (Positive, String);

V : Vectors.Vector;
begin
V.Append ("Mmm");
end Anon;

我不确定为什么没有检测到,或者是否应该检测到(即使预编译,编译器库也应该有包含此信息的 .ali 文件)。如果没有,有没有办法做到这一点?

这是在a-coinve.ads中声明的指针类型,没有任何存储池:type Elements_Access is access all Elements_Type; 这在body中使用正则

(经过编辑以澄清我指的是来自默认池的分配,而不是匿名访问类型)。

最佳答案

如果我没记错的话,您可以为所有 访问类型(包括那些在标准库中声明的)覆盖默认存储池。

我找到的第一个选项是 LRM 中的 13.11.3。它看起来不像我内存中的那样,但是pragma Default_Storage_Pool (null);用作配置 pragma 应该 - 据我所知 - 也涵盖运行时库。

关于ada - 检测 GNAT 预定义库中的匿名分配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51286450/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com