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-27 17:55:34 PST Path: nntp.gmd.de!newsserver.jvnc.net!news.cac.psu.edu!news.pop.psu.edu!hudson.lm.com!newsfeed.pitt.edu!gatech!newsxfer.itd.umich.edu!zip.eecs.umich.edu!panix!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: 27 Oct 1994 09:29:42 -0400 Organization: Courant Institute of Mathematical Sciences Message-ID: <38oa06$7og@gnat.cs.nyu.edu> References: <38nces$bdv@news.delphi.com> NNTP-Posting-Host: gnat.cs.nyu.edu Date: 1994-10-27T09:29:42-04:00 List-Id: That's quite right, C does NOT specify how the bits are layed out. It lacks anything equivalent to record rep clauses, and this can often be a real pain when interfacing to external hardware. The bit fields of C correspond most closely to Ada in which you have given the size of each component and then you say pragma Pack for the record. There is no guarantee here either of any specific ordering or layout, although simple cases, like 8 booleans in a byte, should certainly work, but the ordering of the fields will still be indeterminate. What is true is that if you use pragma Convention (C,..) on such a type in Ada 9X, then this packed record should be layed out the same way that C would lay it out, whatever that is, and for some applications it is this correspondence with the way some other language does things that is important, not the specific layout. As I noted before, in GNAT, Ada and C by default share the same convention for data layout, so pragma Converion (C, ...) would do nothing. Of course if you *do* need to specify the exact layout, then you are in much better shape in Ada, because of the record representation clause. The Bit_Order capability of Ada 9X further adds to the degree of control that is the hands of an Ada programmer. This is one of the respects in which people who make the common assumption that C is somehow inherently better than Ada for low level systems stuff are quite wrong, in this particular area, Ada has much stronger tools than C. Of course you need a decent Ada compiler that implements all these tools correctly, and in the past, there have been some legitimate complaints in this area, but the cure is to insist on better implementations, not to complain about non-existent shortcomings in the language itself.