comp.lang.ada
 help / color / mirror / Atom feed
From: "Rupert Pigott" <darkboo-remove-this-ng.@hotmail.com>
Subject: Re: Import a type from C
Date: Wed, 8 Jan 2003 20:46:23 -0000
Date: 2003-01-08T20:46:23+00:00	[thread overview]
Message-ID: <avi2mt$75l$1$830fa17d@news.demon.co.uk> (raw)
In-Reply-To: u7kfqjnvv.fsf@gsfc.nasa.gov

"Stephen Leake" <stephen.a.leake.1@gsfc.nasa.gov> wrote in message
news:u7kfqjnvv.fsf@gsfc.nasa.gov...
> "Frank J. Lhota" <NOSPAM.lhota.adarose@verizon.net> 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





  reply	other threads:[~2003-01-08 20:46 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-11-06 19:48 Import a type from C Francisco Santoyo
2002-11-06 20:06 ` Frank J. Lhota
2002-11-06 23:10   ` Stephen Leake
2003-01-08 20:46     ` Rupert Pigott [this message]
2003-01-10  3:48       ` Eric G. Miller
2003-01-14  4:47       ` David Thompson
2002-11-07  7:16 ` Victor Porton
2002-11-07 13:47   ` Stephen Leake
2002-11-07 16:03   ` Frank J. Lhota
2002-11-07 16:20     ` Robert A Duff
2002-11-08 14:51       ` Stephen Leake
2002-11-07 19:00 ` chris.danx
2002-11-08  4:02 ` Victor Porton
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox