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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,cd9fd73b6a96d80d,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-10-20 09:52:29 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: bbarker@ball.com (Brian Barker) Newsgroups: comp.lang.ada Subject: Byte Swapping Constrained Data Types Date: 20 Oct 2003 09:52:28 -0700 Organization: http://groups.google.com Message-ID: NNTP-Posting-Host: 162.18.24.24 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1066668748 12670 127.0.0.1 (20 Oct 2003 16:52:28 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 20 Oct 2003 16:52:28 +0000 (UTC) Xref: archiver1.google.com comp.lang.ada:1209 Date: 2003-10-20T09:52:28-07:00 List-Id: ObjectAda for Windows 7.2.2 Native This is more of an Ada specific question if someone could help me. I have declared an enumerated type like so: type Terminal is ( Null_Terminal, Primary, Secondary, Console ); for Terminal use ( Null_Terminal => 0, Primary => 1, Secondary => 2, Console => 3); for Terminal'Size use 32; I also have created a procedure based off of a generic byte-swap routine: procedure Swap is new Endian.Generic_Swap(Terminal); I receive a record over TCP/IP and it is in Big Endian format, so I must byte swap it. I have already copied the raw network data into my structure that contains the Terminal type. When I try to byte swap it I receive a constraint error, because the big endian value of Terminal is out of range. Swap(My_Record.Sending_Terminal); -- <- Sending_Terminal is of type Terminal I want to keep the generic swap, because I have so many abstract data types. I just want to get around this constraint range check when I try to pass the value into the swap routine. Does anyone have a better suggestion?