comp.lang.ada
 help / color / mirror / Atom feed
From: vladimir@speedy.intrepid.com (Vladimir Vukicevic)
Subject: Re: C++ to Ada95, help please
Date: 24 Mar 1995 09:07:28 GMT
Date: 1995-03-24T09:07:28+00:00	[thread overview]
Message-ID: <VLADIMIR.95Mar24010728@speedy.intrepid.com> (raw)
In-Reply-To: sal714@rs710.gsfc.nasa.gov's message of 23 Mar 1995 18:01:33 GMT

In article <SAL714.95Mar23130133@rs710.gsfc.nasa.gov> sal714@rs710.gsfc.nasa.gov (Stephen A. Leake) writes:

: type DISCRIMINANTS is (One, Two);
: for DISCRIMINANTS use (One => ?, Two => ?);
: type struct_STRUCT_NAME (item1 : DISCRIMINANTS) is
: record
: 	case item1 is
: 	when One =>
: 		u_item1 : int;
: 	when Two =>
: 		u_item2 : int;
: 	end case;
: 	item2 : int
: end record;
: 
: If item1 (or item2) is not used in this way, there is no direct Ada
: equivalent structure (and the C code is not very good!).

Of course, a representation clause for the record is needed above, as
there are no guarantees that the Ada compiler will arrange this record
in memory to correspond to the C struct/union. Something like the following
is needed:

for struct_STRUCT_NAME use
	record
		item1 at 0 range 0 .. 7;
		u_item1 at 1 range 0 .. 7;
		u_item2 at 1 range 0 .. 7;
		item2 at 2 range 0 ..7;
	end record;

Note that, because of 13.5.1 (11), you can't just define a record rep
clause with overlapping components; they must be distinct variants.

	- Vladimir



  reply	other threads:[~1995-03-24  9:07 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1995-03-20  8:06 C++ to Ada95, help please Simon Johnston
1995-03-21 23:27 ` Kevin F. Quinn
1995-03-22  5:07   ` Vladimir Vukicevic
1995-03-22  1:22 ` Tucker Taft
1995-03-22 11:38   ` Robb Nebbe
1995-03-23 12:28   ` Mike Meier
1995-03-23 18:31     ` Tucker Taft
1995-03-24 21:24     ` Robert Dewar
1995-03-27 14:58       ` Norman H. Cohen
1995-03-23 13:30   ` Robert Dewar
1995-03-23 18:01 ` Stephen A. Leake
1995-03-24  9:07   ` Vladimir Vukicevic [this message]
1995-03-25 10:02     ` Keith Thompson
  -- strict thread matches above, loose matches on Subject: below --
1995-03-08  7:54 Simon Johnston
1995-03-08 13:56 ` Robert A Duff
1995-03-09 21:23 ` Tucker Taft
replies disabled

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