从地址初始化类型

问题描述 投票:0回答:1

我想从

System.address
初始化一个类型。例如:

generic
    type T_Generic is private;
package MyPackage is
    G_Addr : System.Address;
    procedure Register (myAddr : System.address);
    procedure MyProcedure (myAddr : System.address);
end MyPackage;

package body MyPackage is
    procedure Register(myAddr : System.address)
    is
        G_Addr := myAddr;
    end MyProcedure;

    procedure MyProcedure (myAddr : System.address)
        myVar : T_Generic with address => myAddr;
    is
        if (myAddr = G_Addr)
        then
            -- work with myVar 
        end if;
    end MyProcedure;
end MyPackage;
    

但是我无法编译这段代码

myVar : T_Generic with address => myAddr;
:

方面规范是 Ada 2012 的一项功能

单元必须使用 -gnat2012 开关进行编译

我无法更改编译选项,我该怎么办?

ada memory-address
1个回答
0
投票

但是我无法编译这段代码

myVar : T_Generic with address => myAddr;
:

方面规范是 Ada 2012 的一项功能

单元必须使用 -gnat2012 开关进行编译

My_Address  :  Constant System.Address:= To_Address( 16#DEAD_BEEF# );
My_Variable :  Whatever;
For My_Variable'Address use My_Address;
© www.soinside.com 2019 - 2024. All rights reserved.