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=-0.8 required=5.0 tests=BAYES_00,INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,a5aa52a6f866183 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 1994-10-26 05:27:53 PST Path: nntp.gmd.de!newsserver.jvnc.net!news.cac.psu.edu!news.pop.psu.edu!psuvax1!uwm.edu!news.alpha.net!news.mathworks.com!zombie.ncsc.mil!admii!cmcl2!thecourier.cims.nyu.edu!thecourier.cims.nyu.edu!nobody From: dewar@cs.nyu.edu (Robert Dewar) Newsgroups: comp.lang.ada Subject: Re: Flags in Ada? Date: 26 Oct 1994 07:01:45 -0400 Organization: Courant Institute of Mathematical Sciences Message-ID: <38lcup$ibq@schonberg.cs.nyu.edu> References: <38k89k$kfk@goanna.cs.rmit.oz.au> NNTP-Posting-Host: schonberg.cs.nyu.edu Date: 1994-10-26T07:01:45-04:00 List-Id: The natural way of representing flags, i.e. words in which individual bits have names and can be manipulated is to use pragma pack (some implementations may require you to use a record representation clause, but this should not be necessary, and is a weakness in the implementation). type Flag_Byte is record Flag1 : Boolean; ... Flag8 : Boolean; end record; for Flag_Byte'Size use 8; pragma Pack (Flag_Byte); That should work fine (certainly works fine on GNAT, where it is equivalent to the obviously corresponding C declaration with bit fields of length 1) If sometimes you need to regard this as an integer, then you need to use unchecked conversion -- quite an appropriate use of unchecked conversion, since you are asking to view the same data as two totally different types.