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-Thread: 103376,f7c38a023cf370dc X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news2.google.com!news.glorb.com!solaris.cc.vt.edu!news.vt.edu!newsfeed-00.mathworks.com!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Should representation clauses be complete for each bit? Date: Thu, 21 Jul 2011 11:06:28 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <73c10395-ec4f-4a02-b0fc-e35bc14424fa@e18g2000vbx.googlegroups.com> <4e26f324$0$6549$9b4e6d93@newsspool4.arcor-online.net> <4e27f4ba$0$6584$9b4e6d93@newsspool3.arcor-online.net> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls6.std.com 1311260789 22146 192.74.137.71 (21 Jul 2011 15:06:29 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Thu, 21 Jul 2011 15:06:29 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:0iDlAfS2sS5ZbWhoe/izUR3aWFk= Xref: g2news2.google.com comp.lang.ada:21241 Date: 2011-07-21T11:06:28-04:00 List-Id: Georg Bauhaus writes: > More specifically, if the original example of "not all bits used and some > gaps between them" is unusual, is it so > > - when mapping to a set of hardware pins, say? Whenever I see documentation for such things, they have rectangular pictures showing what every bit means. They don't have implicit gaps. If there are any gaps, they are shown explicitly, as "must be zero" or "reserved for future hardware extensions" or whatever. My claim is that the Ada code interfacing to such a thing should be similarly explicit about the gaps. Otherwise, you end up with nasty bugs: one compiler just happens to set the gaps to zero, and you write to a file, and binary comparisons of those files work. Then you port to a different compiler, and it puts arbitrary junk in the gaps. > - or when "interfacing" to C structs? > > For C structs, declaration order seems very convenient, as C keeps > declaration order. But C may well introduce gaps between structure > components whenever its alignment rules requires. Then I will want > gaps in Ada, too. Is a convention pragma sufficient, then? Right, pragma Convention(C) will properly interface to a C struct, so long as the Ada record matches the C struct component-for-component, and you're using a C compiler supported (for interfacing) by the Ada compiler -- it's the Ada compiler's job to make the layout match what that particular C compiler does. And Convention(C) will prevent reordering of components. - Bob