From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,d233b131fc3b7ba7 X-Google-Attributes: gid103376,public From: "David C. Hoos, Sr." Subject: Re: Help: Storage size Date: 1999/07/13 Message-ID: <7mf7lp$c9g@hobbes.crc.com>#1/1 X-Deja-AN: 500474473 References: <7mejue$9lk$1@nnrp1.deja.com> Organization: Coleman Research Corporation X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3612.1700 Newsgroups: comp.lang.ada Date: 1999-07-13T00:00:00+00:00 List-Id: 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.