comp.lang.ada
 help / color / mirror / Atom feed
* Learning Ada-What does this mean.
@ 2002-09-11 11:58 prashna
  2002-09-11 12:26 ` Georg Bauhaus
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: prashna @ 2002-09-11 11:58 UTC (permalink / raw)


Hi all,
1)Have a look at following piece of code and pls let me what does it
mean?
   type T_MEM_IO is
      record
         INT_1    : T_INTEGER;
         INT_2    : T_INTEGER;
      end record;
   for T_MEM_IO use
      record
         INT_1 at 0 range 0..31;
         INT_2 at 1 range 0..31;
      end record;

2)The code shown above is compiling perfectly when compiled using
tartan compiler(on AIX), but giving error when compiled using gnat(on
windows 2000).Why is it so?

Any help will be appriciated.



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

* Re: Learning Ada-What does this mean.
  2002-09-11 11:58 Learning Ada-What does this mean prashna
@ 2002-09-11 12:26 ` Georg Bauhaus
  2002-09-13  4:24   ` prashna
  2002-09-11 14:04 ` Stephen Leake
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 11+ messages in thread
From: Georg Bauhaus @ 2002-09-11 12:26 UTC (permalink / raw)


prashna <vashwath@rediffmail.com> wrote:
:         INT_1    : T_INTEGER;
:         INT_2    : T_INTEGER;

:         INT_1 at 0 range 0..31;
:         INT_2 at 1 range 0..31;

: 2)The code shown above is compiling perfectly when compiled using
: tartan compiler(on AIX), but giving error when compiled using gnat(on
: windows 2000).Why is it so?

What is T_INTEGER? I get different and plausible complaints
depending on how I define T_INTEGER. How is it defined in your
case?

-- Georg



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

* Re: Learning Ada-What does this mean.
  2002-09-11 11:58 Learning Ada-What does this mean prashna
  2002-09-11 12:26 ` Georg Bauhaus
@ 2002-09-11 14:04 ` Stephen Leake
  2002-09-11 14:31 ` Pascal Obry
  2002-09-11 18:40 ` tmoran
  3 siblings, 0 replies; 11+ messages in thread
From: Stephen Leake @ 2002-09-11 14:04 UTC (permalink / raw)


vashwath@rediffmail.com (prashna) writes:

> Hi all,
> 1)Have a look at following piece of code and pls let me what does it
> mean?

This is a fairly reasonable question. However, it helps if you tell
us what you think it means, or what you want it to mean.

>    type T_MEM_IO is
>       record
>          INT_1    : T_INTEGER;
>          INT_2    : T_INTEGER;
>       end record;

You do not show how T_INTEGER is defined, so I can't answer your
question. The general rule here is to post _compilable_ examples. That
means make a small program (called Learning_Ada, or whatever), that
defines _all_ types needed. That makes things much clearer.

>    for T_MEM_IO use
>       record
>          INT_1 at 0 range 0..31;
>          INT_2 at 1 range 0..31;
>       end record;

Do you know that this is called a record representation clause? You
need to give us a better clue as to what you don't understand.

> 2)The code shown above is compiling perfectly when compiled using
> tartan compiler(on AIX), but giving error when compiled using gnat(on
> windows 2000).Why is it so?

Post the exact error messages, then we can help.

> Any help will be appriciated.

Please try again.

-- 
-- Stephe



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

* Re: Learning Ada-What does this mean.
  2002-09-11 11:58 Learning Ada-What does this mean prashna
  2002-09-11 12:26 ` Georg Bauhaus
  2002-09-11 14:04 ` Stephen Leake
@ 2002-09-11 14:31 ` Pascal Obry
  2002-09-11 14:50   ` Peter Hermann
  2002-09-11 18:40 ` tmoran
  3 siblings, 1 reply; 11+ messages in thread
From: Pascal Obry @ 2002-09-11 14:31 UTC (permalink / raw)



vashwath@rediffmail.com (prashna) writes:

> Hi all,
> 1)Have a look at following piece of code and pls let me what does it
> mean?
>    type T_MEM_IO is
>       record
>          INT_1    : T_INTEGER;
>          INT_2    : T_INTEGER;
>       end record;
>    for T_MEM_IO use
>       record
>          INT_1 at 0 range 0..31;
>          INT_2 at 1 range 0..31;
>       end record;

This is a representation clause (see RM.13). It is used to layout the data
in memory.

> 2)The code shown above is compiling perfectly when compiled using
> tartan compiler(on AIX), but giving error when compiled using gnat(on
> windows 2000).Why is it so?

Hard to tell without the T_INTEGER definition.

Pascal.

-- 

--|------------------------------------------------------
--| Pascal Obry                           Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--|         http://perso.wanadoo.fr/pascal.obry
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver wwwkeys.pgp.net --recv-key C1082595



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

* Re: Learning Ada-What does this mean.
  2002-09-11 14:31 ` Pascal Obry
@ 2002-09-11 14:50   ` Peter Hermann
  0 siblings, 0 replies; 11+ messages in thread
From: Peter Hermann @ 2002-09-11 14:50 UTC (permalink / raw)


Pascal Obry <p.obry@wanadoo.fr> wrote:
> vashwath@rediffmail.com (prashna) writes:
>>    type T_MEM_IO is
>>       record
>>          INT_1    : T_INTEGER;
[snip]
> This is a representation clause (see RM.13). It is used to layout the data
> in memory.
>> 2)The code shown above is compiling perfectly when compiled using
>> tartan compiler(on AIX), but giving error when compiled using gnat(on
>> windows 2000).Why is it so?
> Hard to tell without the T_INTEGER definition.

if t_integer is a special tartan compiler type and not imported by 
a with clause, then the tartan compiler may not be validated.

Vashwath, you always should send the complete compilation unit!

And to myself: I should not have replied to incomplete code pieces:
I am realizing my "too much speculation".

-- 
--Peter Hermann(49)0711-685-3611 fax3758 ica2ph@csv.ica.uni-stuttgart.de
--Pfaffenwaldring 27 Raum 114, D-70569 Stuttgart Uni Computeranwendungen
--http://www.csv.ica.uni-stuttgart.de/homes/ph/
--Team Ada: "C'mon people let the world begin" (Paul McCartney)



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

* Re: Learning Ada-What does this mean.
  2002-09-11 11:58 Learning Ada-What does this mean prashna
                   ` (2 preceding siblings ...)
  2002-09-11 14:31 ` Pascal Obry
@ 2002-09-11 18:40 ` tmoran
  2002-09-13  4:19   ` prashna
  3 siblings, 1 reply; 11+ messages in thread
From: tmoran @ 2002-09-11 18:40 UTC (permalink / raw)


>  type T_MEM_IO is
>     record
> ...
  This declares a record structure called T_MEM_IO.
>  for T_MEM_IO use
>     record
>        INT_1 at 0 range 0..31;
>        INT_2 at 1 range 0..31;
>     end record;
  This "record representation clause"
tells the compiler you want the record laid out in memory in a
certain way (otherwise the compiler could move things around or
leave empty filler bytes for instance).  This particular one says
that INT_1 should start at the first "storage element" and occupy
its first 32 bits.  INT_2 should start at the second storage element
and occupy its first 32 bits.

> 2)The code shown above is compiling perfectly when compiled using
> tartan compiler(on AIX), but giving error when compiled using gnat(on
> windows 2000).Why is it so?
If a "storage element" on the target machine is 32 bits wide, then the
first one will hold INT_1 and the second INT_2.  Is a storage element on
AIX 32 bits wide?  On a PC a "storage element" is an 8 bit byte, so INT_1
occupies the first 4 bytes.  INT_2 starts at the second byte, ie, 1/4 of
the way into INT_1, and takes the next 4 bytes.  So INT_1 and INT_2
overlap on a PC.  This is illegal, and the Gnat compilation error message
ought to be telling you that.
For the PC you probably want instead
  for T_MEM_IO use
     record
        INT_1 at 0 range 0..31;
        INT_2 at 4 range 0..31;
     end record;
so INT_2 starts right after INT_1.

But why have a representation clause at all?  If the record is used purely
internally, and not read/written by other programs, the OS, or hardware,
then you probably don't care how the compiler laid out the record, and
you might as well let it perform any optimization tricks it knows.  If the
record is shared with the outside world, then you may have to worry about
things like endianness which might be different between a PC and an AIX.
The name "T_MEM_IO" suggests this record might indeed be something used
by a hardware device - is that going to work the same on the PC as the AIX?



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

* Re: Learning Ada-What does this mean.
  2002-09-11 18:40 ` tmoran
@ 2002-09-13  4:19   ` prashna
  2002-09-13  4:52     ` tmoran
  2002-09-13 11:00     ` David C. Hoos, Sr.
  0 siblings, 2 replies; 11+ messages in thread
From: prashna @ 2002-09-13  4:19 UTC (permalink / raw)


> If a "storage element" on the target machine is 32 bits wide, then the
Thanks tmoran, thank u very much.
> first one will hold INT_1 and the second INT_2.  Is a storage element on
> AIX 32 bits wide?  On a PC a "storage element" is an 8 bit byte, so INT_1
> occupies the first 4 bytes.  INT_2 starts at the second byte, ie, 1/4 of
> the way into INT_1, and takes the next 4 bytes.  So INT_1 and INT_2
> overlap on a PC.  This is illegal, and the Gnat compilation error message
> ought to be telling you that.
u r right tmoran and This was the error message that gnat was giving,
"component "DATE_32" overlaps "WORD"".
Sorry for not posting this(error message) in my original post.
One more help tmoran,How do we now what is the size of the storage
element?

> For the PC you probably want instead
>   for T_MEM_IO use
>      record
>         INT_1 at 0 range 0..31;
>         INT_2 at 4 range 0..31;
>      end record;
> so INT_2 starts right after INT_1.
> The name "T_MEM_IO" suggests this record might indeed be something used
> by a hardware device - is that going to work the same on the PC as the AIX?

I have no Idea of what This record does coz I have just entered in to
this software field and I am doing code walk through and I came across
this piece of code.

Thanks for all those who have replied.



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

* Re: Learning Ada-What does this mean.
  2002-09-11 12:26 ` Georg Bauhaus
@ 2002-09-13  4:24   ` prashna
  2002-09-13 12:46     ` Georg Bauhaus
  0 siblings, 1 reply; 11+ messages in thread
From: prashna @ 2002-09-13  4:24 UTC (permalink / raw)


> What is T_INTEGER? I get different and plausible complaints
> depending on how I define T_INTEGER. How is it defined in your
> case?

It is defined like this "type I_INTEGER is range -2**31 .. 2**31 -1;
The error it is giving is "component "DATE_32" overlaps "WORD"".

> -- Georg



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

* Re: Learning Ada-What does this mean.
  2002-09-13  4:19   ` prashna
@ 2002-09-13  4:52     ` tmoran
  2002-09-13 11:00     ` David C. Hoos, Sr.
  1 sibling, 0 replies; 11+ messages in thread
From: tmoran @ 2002-09-13  4:52 UTC (permalink / raw)


> One more help tmoran,How do we now what is the size of the storage element?
  The ARM discussion of the representation clause references 'Position,
which is defined as an address offset from the start, so what you need
to know is the number of bits from address X to X+1.  That's of course
an 8 bit byte on a PC.  Is it a 32 bit word on the AIX?



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

* Re: Learning Ada-What does this mean.
  2002-09-13  4:19   ` prashna
  2002-09-13  4:52     ` tmoran
@ 2002-09-13 11:00     ` David C. Hoos, Sr.
  1 sibling, 0 replies; 11+ messages in thread
From: David C. Hoos, Sr. @ 2002-09-13 11:00 UTC (permalink / raw)



----- Original Message ----- 
From: "prashna" <vashwath@rediffmail.com>
Newsgroups: comp.lang.ada
To: <comp.lang.ada@ada.eu.org>
Sent: September 12, 2002 11:19 PM
Subject: Re: Learning Ada-What does this mean.


<snip>
> One more help tmoran,How do we now what is the size of the storage
> element?
The constant System.Storage_Unit gives the size of a Storage_Unit
in bits.






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

* Re: Learning Ada-What does this mean.
  2002-09-13  4:24   ` prashna
@ 2002-09-13 12:46     ` Georg Bauhaus
  0 siblings, 0 replies; 11+ messages in thread
From: Georg Bauhaus @ 2002-09-13 12:46 UTC (permalink / raw)


prashna <vashwath@rediffmail.com> wrote:
: 
: It is defined like this "type I_INTEGER is range -2**31 .. 2**31 -1;
: The error it is giving is "component "DATE_32" overlaps "WORD"".

As Tom has explained, you will need to know how many bits
your integer type must at least consume, and then how many
storage elements you need to place all the bits in them.
(Whether theses storage elements are octets, 9-bit bytes,
32bit words, ... should be found in your compiler documentation 
or some file in the compiler distribution, or ...)
This will give you the offset of the second component, that is its
first storage element, in the record.

Maybe you can try to persuade your employers to obtain
a copy of "Ada as a Second Language", 2nd edition, N. Cohen,
which discusses the issues very clearly.

-- Georg



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

end of thread, other threads:[~2002-09-13 12:46 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-09-11 11:58 Learning Ada-What does this mean prashna
2002-09-11 12:26 ` Georg Bauhaus
2002-09-13  4:24   ` prashna
2002-09-13 12:46     ` Georg Bauhaus
2002-09-11 14:04 ` Stephen Leake
2002-09-11 14:31 ` Pascal Obry
2002-09-11 14:50   ` Peter Hermann
2002-09-11 18:40 ` tmoran
2002-09-13  4:19   ` prashna
2002-09-13  4:52     ` tmoran
2002-09-13 11:00     ` David C. Hoos, Sr.

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