comp.lang.ada
 help / color / mirror / Atom feed
* How can you convert.....
@ 2001-10-03  7:32 Zebylon
  2001-10-03  8:54 ` Petter Fryklund
  2001-10-03 12:14 ` James Rogers
  0 siblings, 2 replies; 5+ messages in thread
From: Zebylon @ 2001-10-03  7:32 UTC (permalink / raw)


...an System.Adress type to an Unsigned_32?


/S





^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: How can you convert.....
  2001-10-03  7:32 How can you convert Zebylon
@ 2001-10-03  8:54 ` Petter Fryklund
  2001-10-03 17:38   ` Stephen Leake
  2001-10-03 12:14 ` James Rogers
  1 sibling, 1 reply; 5+ messages in thread
From: Petter Fryklund @ 2001-10-03  8:54 UTC (permalink / raw)


If it is convertiable, by

with Ada.Unchecked_Conversion;
with System;
with Interfaces;
...
...
   function "+" is new Ada.Unchecked_Conversion (Source => System.Adress,
Target =>   Interfaces.Unsigned_32);
    Adr : System.Address;
      U  : Interfaces.Unsigned_32;
begin

    ....
    .....
    U := + Adr;




Zebylon wrote in message <9pedqp$m5l$1@newstoo.ericsson.se>...
>...an System.Adress type to an Unsigned_32?
>
>
>/S
>
>





^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: How can you convert.....
  2001-10-03  7:32 How can you convert Zebylon
  2001-10-03  8:54 ` Petter Fryklund
@ 2001-10-03 12:14 ` James Rogers
  1 sibling, 0 replies; 5+ messages in thread
From: James Rogers @ 2001-10-03 12:14 UTC (permalink / raw)


Zebylon wrote:
> 
> ...an System.Adress type to an Unsigned_32?

The real question is "why do you want to do this?"

This sounds to me like trying to write C in Ada.

The package System defines comparison functions for type Address.
The package System.Storage_Elements defines arithmetic for
type Address. 

Perhaps you are trying to deal with passing pointers in C.
In that case, System.Address is more appropriate than Unsigned_32.
Unsigned_32 is a non-portable representation of an address.

Jim Rogers
Colorado Springs, Colorado USA



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: How can you convert.....
  2001-10-03  8:54 ` Petter Fryklund
@ 2001-10-03 17:38   ` Stephen Leake
  2001-10-04 19:44     ` tmoran
  0 siblings, 1 reply; 5+ messages in thread
From: Stephen Leake @ 2001-10-03 17:38 UTC (permalink / raw)


"Petter Fryklund" <qsbpefr@esavionics.se> writes:

> If it is convertiable, by
> 
> with Ada.Unchecked_Conversion;
> with System;
> with Interfaces;
> ...
> ...
>    function "+" is new Ada.Unchecked_Conversion (Source => System.Adress,
> Target =>   Interfaces.Unsigned_32);
>     Adr : System.Address;
>       U  : Interfaces.Unsigned_32;
> begin
> 
>     ....
>     .....
>     U := + Adr;
> 

This will probably work, but there is a better way, which is
guarranteed by the compiler. See System.Storage_Elements.To_Integer.
This function converts an address into an appropriate integer type.

Note that on some systems, an address has less than 32 bits, and on
others, it has more.

-- 
-- Stephe



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: How can you convert.....
  2001-10-03 17:38   ` Stephen Leake
@ 2001-10-04 19:44     ` tmoran
  0 siblings, 0 replies; 5+ messages in thread
From: tmoran @ 2001-10-04 19:44 UTC (permalink / raw)


>See System.Storage_Elements.To_Integer.
>This function converts an address into an appropriate integer type.
>
>Note that on some systems, an address has less than 32 bits, and on
>others, it has more.
  What do compilers do on systems where addresses are multi-part,
eg a segmented address space?  Also, what rules prevent X'Address
where X is in a different partition?



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2001-10-04 19:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-10-03  7:32 How can you convert Zebylon
2001-10-03  8:54 ` Petter Fryklund
2001-10-03 17:38   ` Stephen Leake
2001-10-04 19:44     ` tmoran
2001-10-03 12:14 ` James Rogers

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