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,fd173879a595bde X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!news.glorb.com!news.banetele.no!dotsrc.org!news.dotsrc.org!not-for-mail Date: Sat, 05 Nov 2005 16:39:21 +0200 Subject: Re: Default rep specs for record types - documented?? Newsgroups: comp.lang.ada References: From: "Martin Krischik" Content-Type: text/plain; format=flowed; delsp=yes; charset=utf-8 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID: User-Agent: Opera M2/8.50 (Win32, build 7700) Organization: SunSITE.dk - Supporting Open source NNTP-Posting-Host: 213.154.204.111 X-Trace: news.sunsite.dk DXC=LRCfOGa?ALej?5fOS\LBAnYSB=nbEKnkk`0G6fE2o=alS5daR30PdPeV:_8RJBabHm;O^i0GOe`^cQ0@8]fPl=FnVHNf Am 05.11.2005, 05:33 Uhr, schrieb Anonymous Coward : > Perhaps, but for interfacing with C operations (which is my case), I > would prefer to simply write "pragma convention (C, my_record)" and be > able to expect the compiler to base the representational spec purely > off the operational spec, just as the C compiler would for a structure > that only has an operational spec. Well, it should actualy work - unless you use an incompatible C compiler. You see: pragma convention (C... will only work with the appropiate sister C compiler. In case of GNAT it is the gcc. Problem is that most C compiler will unpack records in order to speed up access to the data. That is so ever since we moved from 8 bit CPUs to 16bit CPUs and accessing an even address became faster then accessing an odd address. On 32 bit CPUs data might even be unpacked to addresses which can be devided by 4. or 8 on 64 bit CPUs. Or not at all since modern MMU (Memeory Management Units) and multiple cache buffer might make accessing an odd address just as fast then an even address reverting the hole trent again. It's all a big maybe. And you might even get that trouble when you are using 2 diffrent C compilers. Like a 3rd party lib compiled with C compiler 1 optimizing for i386 and you use C compiler 2 optimizing for x86_64. Most C compilers have "#pragma pack (...)" to solve the mess. And Ada has "for Record_Type'Alignment use ...;" Martin