This is the mail archive of the
libffi-discuss@sourceware.org
mailing list for the libffi project.
Re: does it matter how I construct an aggregate struct type if its size is the same?
- From: Hayden Livingston <halivingston at gmail dot com>
- To: Andrew Haley <aph at redhat dot com>
- Cc: libffi-discuss at sourceware dot org
- Date: Fri, 18 Dec 2015 07:16:43 -0800
- Subject: Re: does it matter how I construct an aggregate struct type if its size is the same?
- Authentication-results: sourceware.org; auth=none
- References: <CAMxMwy+ATViiyo4Znn4-jhmoKNEDWbHUxFPOmK6sX9_Lxd_j0w at mail dot gmail dot com> <5673E92C dot 7090400 at redhat dot com>
Thanks, Andrew. Where is this exception? In ABIs?
So you're suggesting I use char's to construct my ffi_types?
On Fri, Dec 18, 2015 at 3:08 AM, Andrew Haley <aph@redhat.com> wrote:
> On 18/12/15 06:46, Hayden Livingston wrote:
>> This may be a fundamental question, but does it matter how a struct is
>> constructed if its size is accurate to the receiving function? That is
>> if it was made up of all int8s vs. a combination of other types?
>
> Yes, it does. But there is a specific exception for character types:
> a character type is permitted to alias all other types. So it's
> always safe to use an array of char, say, to hold anything. (Without
> this rule, malloc() would not work.)
>
> Andrew.
>