comp.lang.ada
 help / color / mirror / Atom feed
* Unchecked_Conversion on different sized types -- problem?
@ 2000-01-13  0:00 Mike Silva
  2000-01-13  0:00 ` reason67
                   ` (7 more replies)
  0 siblings, 8 replies; 21+ messages in thread
From: Mike Silva @ 2000-01-13  0:00 UTC (permalink / raw)


To do some prototyping I'm extending Michael Feldman's ANSI screen package a
bit, to allow colors, etc, and I ran into a question.  I've enumerated
various attributes and set the enumerations to the corresponding ANSI codes,
and I'm using UC to convert the enumerated types to an Integer, to send via
Text_IO.Put().  I get a warning (GNAT 3.12p) that the types for the UC have
different sizes (not surprising), and I'm wondering if UC always does the
"right" thing here, i.e. zero-extending the smaller enum type when
converting to an Integer.

Here are some (reduced) relevant code bits:

type T is ( BLACK, WHITE );

for T use ( BLACK => 30, WHITE => 37 );

function T_to_int is new Unchecked_Conversion( T, Integer );

T_val : T := BLACK;

Text_IO.Put( Item => T_to_int( T_val )...

So, is T_to_int going to give me 30, as opposed to, say, all 32 bits
starting at the address of T_val?  Can somebody tell me where in the LRM it
talks about this?

(It works "as expected" in this case, but I'm wondering what the rules are)

Also, there's not a simpler way to do this that I'm overlooking, is there?

Mike







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

end of thread, other threads:[~2000-01-16  0:00 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-01-13  0:00 Unchecked_Conversion on different sized types -- problem? Mike Silva
2000-01-13  0:00 ` reason67
2000-01-13  0:00 ` Bryce Bardin
2000-01-13  0:00   ` Mike Silva
2000-01-13  0:00     ` Mike Silva
2000-01-14  0:00       ` Bryce Bardin
2000-01-14  0:00         ` Mike Silva
2000-01-14  0:00   ` Matthew Heaney
2000-01-13  0:00 ` Jim Rogers
2000-01-13  0:00   ` Mike Silva
2000-01-13  0:00     ` James S. Rogers
2000-01-14  0:00 ` Vladimir Olensky
2000-01-14  0:00 ` Wrap-Up (was Re: Unchecked_Conversion on different sized types -- problem?) Mike Silva
2000-01-15  0:00   ` Matthew Heaney
2000-01-15  0:00     ` Robert A Duff
2000-01-14  0:00 ` Unchecked_Conversion on different sized types -- problem? Werner Pachler
2000-01-14  0:00   ` reason67
2000-01-14  0:00   ` Bryce Bardin
2000-01-14  0:00 ` Jeff Carter
2000-01-14  0:00 ` Keith Thompson
2000-01-16  0:00   ` David A. Cobb

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