Next: Pragma Annotate, Previous: Pragma Ada_2012, Up: Implementation Defined Pragmas [Contents][Index]
Syntax:
pragma Allow_Integer_Address;
In almost all versions of GNAT, System.Address
is a private
type in accordance with the implementation advice in the RM. This
means that integer values,
in particular integer literals, are not allowed as address values.
If the configuration pragma
Allow_Integer_Address
is given, then integer expressions may
be used anywhere a value of type System.Address
is required.
The effect is to introduce an implicit unchecked conversion from the
integer value to type System.Address
. The reverse case of using
an address where an integer type is required is handled analogously.
The following example compiles without errors:
pragma Allow_Integer_Address; with System; use System; package AddrAsInt is X : Integer; Y : Integer; for X'Address use 16#1240#; for Y use at 16#3230#; m : Address := 16#4000#; n : constant Address := 4000; p : constant Address := Address (X + Y); v : Integer := y'Address; w : constant Integer := Integer (Y'Address); type R is new integer; RR : R := 1000; Z : Integer; for Z'Address use RR; end AddrAsInt;
Note that pragma Allow_Integer_Address
is ignored if System.Address
is not a private type. In implementations of GNAT
where
System.Address is a visible integer type,
this pragma serves no purpose but is ignored
rather than rejected to allow common sets of sources to be used
in the two situations.