From: tmoran@acm.org
Subject: Re: Making ada (types) "visable" in C
Date: Thu, 27 Jan 2005 11:59:15 -0600
Date: 2005-01-27T11:59:15-06:00 [thread overview]
Message-ID: <VvWdnVw4jO1utmTcRVn-ow@comcast.com> (raw)
In-Reply-To: 6acda821.0501270510.1dbfe551@posting.google.com
> 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.
next prev parent reply other threads:[~2005-01-27 17:59 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-01-27 13:10 Making ada (types) "visable" in C Sebastian
2005-01-27 13:36 ` Lutz Donnerhacke
2005-01-27 17:59 ` tmoran [this message]
2005-01-27 23:06 ` Nick Roberts
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox