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,8ecbc35ea893182f X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!cyclone1.gnilink.net!spamkiller.gnilink.net!gnilink.net!trnddc01.POSTED!7c706d3b!not-for-mail From: David Thompson Newsgroups: comp.lang.ada Subject: Re: Interfacing to C: big structures Organization: Poor Message-ID: References: <62idb0F23ddfnU1@mid.individual.net> <62ip0mF23cobbU1@mid.individual.net> <62iskrF23lre0U1@mid.individual.net> X-Newsreader: Forte Agent 3.3/32.846 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Mon, 10 Mar 2008 01:38:30 GMT NNTP-Posting-Host: 70.104.70.196 X-Complaints-To: abuse@verizon.net X-Trace: trnddc01 1205113110 70.104.70.196 (Sun, 09 Mar 2008 21:38:30 EDT) NNTP-Posting-Date: Sun, 09 Mar 2008 21:38:30 EDT Xref: g2news1.google.com comp.lang.ada:20267 X-Original-Bytes: 1835 Date: 2008-03-10T01:38:30+00:00 List-Id: On Tue, 26 Feb 2008 20:28:48 -0500, Robert A Duff wrote: > "Alex R. Mosteo" writes: > > And, finally, is adding an alignment clause enough to solve this issue? > > If so, how do you query the alignment of a C datatype? > > I'm not a C expert, but I don't think there's any easy way. > Easy is a matter of opinion, and not very elegant, but possible: #include struct S { whatever }; size_t /* or other u-int type */ Alignment_for_S (void) { struct trick { char x; S y; } /* type only no instance */; return offsetof (struct trick, y); } This isn't guaranteed to be minimal, but it is sufficient. - formerly david.thompson1 || achar(64) || worldnet.att.net