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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,6b77ce1ba18f9267 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-01-08 12:46:54 PST Path: archiver1.google.com!news2.google.com!news1.google.com!newsfeed.stanford.edu!bloom-beacon.mit.edu!news-out.cwix.com!newsfeed.cwix.com!newsfeed.icl.net!newsfeed.fjserv.net!kibo.news.demon.net!news.demon.co.uk!demon!not-for-mail From: "Rupert Pigott" Newsgroups: comp.lang.ada Subject: Re: Import a type from C Date: Wed, 8 Jan 2003 20:46:23 -0000 Message-ID: References: NNTP-Posting-Host: darkboong.demon.co.uk X-Trace: news.demon.co.uk 1042058781 7349 80.177.7.220 (8 Jan 2003 20:46:21 GMT) X-Complaints-To: abuse@demon.net NNTP-Posting-Date: Wed, 8 Jan 2003 20:46:21 +0000 (UTC) X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Priority: 3 X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MSMail-Priority: Normal Xref: archiver1.google.com comp.lang.ada:32771 Date: 2003-01-08T20:46:23+00:00 List-Id: "Stephen Leake" wrote in message news:u7kfqjnvv.fsf@gsfc.nasa.gov... > "Frank J. Lhota" writes: > > > pragma Convention( C, My_Data ); > > > > The Convention pragma can be used to specify that this record type should be > > laid out in the same way that a C compiler would. > > Note that "a C compiler" really means "the C compiler that the Ada > compiler knows about, with its default command line args". For > example, GNAT will assume Gnu C, _without_ -fpacked. ObjectAda > probably assumes MS C, again without the "packed" flag. That has > caused me some major problems, when linking against C code compiled > _with_ the -fpacked flag. > > So I always use a rep spec, instead of relying on Convention (C). Then > I write some C code that checks the struct size, to be sure there is > no padding. Perhaps I'm overly pessimistic here... IIRC there is no guarantee of the order of members within a structure in C either. One of those little gotchas (along with no alignment control) that **** portable code and force you to go the long way around... Cheers, Rupert