comp.lang.ada
 help / color / mirror / Atom feed
* access aliased obstacle
@ 1996-07-04  0:00 tmoran
  1996-07-04  0:00 ` Robert Dewar
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: tmoran @ 1996-07-04  0:00 UTC (permalink / raw)



To pass a data structure to an OS routine I tried

  type elements(discriminant: enumeration_type:=normal_value) is record
    case discriminant is
    ...
  end record;
  for elements'size use 64;  -- size does not vary

  type list_of_elements is array(1 .. 17) of aliased elements;

but one of my Ada 95 compilers objected to aliasing unless I make a
subtype with a specific discriminant value, which defeats the purpose.
The LRM appears to me to agree with this compiler.  The only obvious
possibility is unchecked_conversion.  What is the 'right' way?




^ permalink raw reply	[flat|nested] 11+ messages in thread
* Re: access aliased obstacle
@ 1996-07-09  0:00 tmoran
  1996-07-09  0:00 ` Laurent Guerby
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: tmoran @ 1996-07-09  0:00 UTC (permalink / raw)



>Are you trying to interface a C union (array of)? If it's the case,
>I think the use of Unchecked_Union may be of interest (and I believe
>it will be portable between Ada 95 implementation).
  I think of a C union as essentially a variant record with the
discriminant outside the record (in some other variable entirely).
C probably does think of this as a union, although it fits an Ada
discriminated record perfectly.  What is this 'Unchecked_Union'?
I don't see it in my LRM.

>non-limited types.  So, just make type Elements limited (i.e. change "is
>record" to "is limited record") and it will be OK.  There is some
  This is a glue package between Ada and a set of OS routines.  It would
be inconvenient, and hard to explain to users, why these discriminated
records ought to be 'limited'.  So right now I do an Unchecked_Conversion
to a local array of undiscriminated, and thus aliasable, records.  Since
it's in an OS call, and we're not talking enormous arrays, the marginal
performance hit is bearable.  But it sure isn't pretty.




^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~1996-07-10  0:00 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-07-04  0:00 access aliased obstacle tmoran
1996-07-04  0:00 ` Robert Dewar
1996-07-06  0:00 ` Laurent Guerby
1996-07-07  0:00 ` Robert A Duff
  -- strict thread matches above, loose matches on Subject: below --
1996-07-09  0:00 tmoran
1996-07-09  0:00 ` Laurent Guerby
1996-07-09  0:00   ` Robert Dewar
1996-07-09  0:00 ` Laurent Guerby
1996-07-09  0:00   ` Robert Dewar
1996-07-10  0:00     ` Robert A Duff
1996-07-09  0:00 ` Robert Dewar

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