我想声明一些“用户定义的编译器常量”以使我的规范文件尽可能地保持“常量”。这在 C++ 中很常见,例如:
// misc/config.hh
namespace misc
{
typedef std::shared_ptr<A> A_ptr;
namespace arch = ibmpc;
}
// misc/code.hh
#include "misc/config.hh"
namespace misc
{
void function p(A_ptr a);
}
这将在 Ada :
-- misc.ads
package Misc is
use Types; ----> forbidden !
procedure P(A : A_Access);
end Misc;
-- misc-types.ads
package Misc.Types is
type A_Access is A'Access;
end Misc.Types;
当然这不起作用,因为use
它是一个上下文关键字......因此我的问题是:如何在 Ada 中做一些具有相同结果的事情?