comp.lang.ada
 help / color / mirror / Atom feed
From: "David C. Hoos, Sr." <david.c.hoos.sr@ada95.com>
Subject: Re: Help: Storage size
Date: 1999/07/13
Date: 1999-07-13T00:00:00+00:00	[thread overview]
Message-ID: <7mf7lp$c9g@hobbes.crc.com> (raw)
In-Reply-To: 7mejue$9lk$1@nnrp1.deja.com


Adrian Hoe wrote in message <7mejue$9lk$1@nnrp1.deja.com>...
>If I have a C code like this:
>
>typedef unsigned short   CARD16;
>
>and
>
>typedef struct {
>   CARD8     reqType;
>   CARD16    length : 16;
>} tReq;
>
>How can the above struct (record) be implemented in Ada?
>
>Where CARD16 is define as follow in Ada:
>
>type CARD16 is new X.Unsigned_Short;
>
>
>Can anyone please help?
>--
Several problems here -- e.g.:

1. Where is the declaration for CARD8?  This will affect the result.

2. If #pragma pack is used, this will affect the result.

3. If unsigned short is 16 bits on your system, the bit-field
   specification (:16) would appear to be redundant.

4. Where is the declaration for X.Unsigned_Short?

5. Bit-field implementations are compiler-dependent, so from
   the code you supplied (without any compiler or platform
   identification) it is impossible to say for sure what is
   the memory layout of the tReq struct.

If the memory layout of the C struct is known, writing the
Ada declaration is trivial.








  reply	other threads:[~1999-07-13  0:00 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-07-13  0:00 Help: Storage size Adrian Hoe
1999-07-13  0:00 ` David C. Hoos, Sr. [this message]
1999-07-13  0:00   ` Adrian Hoe
1999-07-13  0:00     ` David C. Hoos, Sr.
1999-07-14  0:00       ` Adrian Hoe
1999-07-14  0:00         ` Simon Wright
1999-07-16  0:00           ` Adrian Hoe
1999-07-16  0:00       ` Adrian Hoe
1999-07-14  0:00     ` Keith Thompson
replies disabled

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