comp.lang.ada
 help / color / mirror / Atom feed
From: adambeneschan@gmail.com
Subject: Re: subtype of System.Address type
Date: Thu, 27 Feb 2014 08:06:57 -0800 (PST)
Date: 2014-02-27T08:06:57-08:00	[thread overview]
Message-ID: <a04b14d0-2af1-421b-b8df-6d0dd826609c@googlegroups.com> (raw)
In-Reply-To: <376f729d-2883-4b28-82fa-9a24420e5e6e@googlegroups.com>

On Wednesday, February 26, 2014 9:19:57 PM UTC-8, ashwath...@gmail.com wrote:
> Hello,
> 
> My compiler(GNAT 3.1 ) gives an error for the following statement.
> 
> 
> 
>  subtype MEMORY_RANGE_TYPE is SYSTEM.ADDRESS range 16#0000_0000#..16#7FFF_FFFF#; 
> 
> It says incorrect constraint for this type.
> 
> Kindly let me know the mistake I am doing.

Like everyone else said, System.Address is a private type.  If you really need to use integers as addresses, use System.Storage_Elements.Integer_Address:

   subtype Memory_Range_Type is System.Storage_Elements.Integer_Address range
      16#0000_0000# .. 16#7FFF_FFFF#;

Integer_Address is required to be either a signed or modular integer subtype; either way, the above will work as long as both 0 and 7FFFFFFF are in range for the implementation-defined subtype.  Then, System.Storage_Elements.To_Address(Value) will convert an Integer_Address to a System.Address.  See RM 13.7.1.  (This package has been part of the language since Ada 95.)

      parent reply	other threads:[~2014-02-27 16:06 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-27  5:19 subtype of System.Address type ashwath30jul77
2014-02-27  5:38 ` Shark8
2014-02-27  6:07 ` Jeffrey Carter
2014-02-27 15:33   ` Robert A Duff
2014-02-27 11:25 ` Brian Drummond
2014-02-27 16:06 ` adambeneschan [this message]
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox