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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,6343ad227ef07794 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!news.maxwell.syr.edu!border1.nntp.dca.giganews.com!nntp.giganews.com!local1.nntp.dca.giganews.com!nntp.comcast.com!news.comcast.com.POSTED!not-for-mail NNTP-Posting-Date: Thu, 27 Jan 2005 11:59:15 -0600 From: tmoran@acm.org Newsgroups: comp.lang.ada Subject: Re: Making ada (types) "visable" in C References: <6acda821.0501270510.1dbfe551@posting.google.com> X-Newsreader: Tom's custom newsreader Message-ID: Date: Thu, 27 Jan 2005 11:59:15 -0600 NNTP-Posting-Host: 67.161.24.234 X-Trace: sv3-tJeVfC+RL+x+E2LfJn8ySr0Vets9elqC3AQyllq93Y9N+1spR11j7WfdMsi2QswvRjs9g/I8qWUWh05!/yhoRb/18xbKiqQZYbD46xraCgUYlYMy29b/z7CqIp5foOjcjXux+k8NfaGOJg== X-Complaints-To: abuse@comcast.net X-DMCA-Complaints-To: dmca@comcast.net X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.22 Xref: g2news1.google.com comp.lang.ada:8017 Date: 2005-01-27T11:59:15-06:00 List-Id: > type State_Buff is (Ok, Failed); > > type Baud_Type is (R9600, R19200); > > type Parity_Type is (None, Odd, Even); > > type Stop_Bit_Type is (One, Two); Ada deals with things at the logical level, eg, a State_Buf object either has the value Ok or the value Failed. C deals with bit patterns, and different C compilers running on different OSes or hardware use different bit patterns. Ada provides a way, "representation clauses", to make the compiler use specific bit patterns for its logical types. So, assuming that for your specific application the C bit pattern for a State_Buf object is 32 bits with a value of 0 or 0xFFFFFFFF, you would say type State_Buff is (Ok, Failed); for State_Buff use (Ok => 0, Failed => 16#FFFFFFFF#); for State_Buff'size use 32; Similarly for the other types.