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: Andrew Haley <aph at redhat dot com>
- To: libffi-discuss at sourceware dot org
- Date: Fri, 18 Dec 2015 11:08:28 +0000
- 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>
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.